# Ignition string help needed

**URL:** <https://forum.inductiveautomation.com/t/ignition-string-help-needed/4359>\
**Category:** Ignition\
**Created:** [April 26, 2012, 6:16pm UTC](https://forum.inductiveautomation.com/t/ignition-string-help-needed/4359 "2012-04-26T18:16:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [April 26, 2012, 6:16pm UTC](https://forum.inductiveautomation.com/t/ignition-string-help-needed/4359/1 "2012-04-26T18:16:14Z")

</div>

def post(Message):  
import system, datetime  
now = datetime.datetime.now()  
timeStamp = now  
nameDateFile = now.strftime("%Y%m%d")  
filename = “c://Users//AJ//%s.txt”%(nameDateFile)  
system.file.writeFile(filename, '\r\nIT’S %s ’ %(timeStamp[0:20]), 1)  
system.file.writeFile(filename, str(Message), 1)

I am trying to format a timestamp string so i don’t see microseconds, only the milliseconds.  
Why cant i use python string like [0:22]

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 26, 2012, 6:46pm UTC](https://forum.inductiveautomation.com/t/ignition-string-help-needed/4359/2 "2012-04-26T18:46:32Z")

</div>

You can’t do that because the timeStamp variable is not a string but a date. So do the following:`def post(Message):
	import system, datetime
	now = datetime.datetime.now()
	timeStamp = now
	nameDateFile = now.strftime("%Y%m%d")
	filename = "c://Users//AJ//%s.txt"%(nameDateFile)
        timeStamp = str(timeStamp)
	system.file.writeFile(filename, '\r\nIT\'S %s ' %(timeStamp[0:20]), 1)
	system.file.writeFile(filename, str(Message), 1)`Note the line right before.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [April 26, 2012, 6:55pm UTC](https://forum.inductiveautomation.com/t/ignition-string-help-needed/4359/3 "2012-04-26T18:55:59Z")

</div>

thanks. it worked
