Python Help With Date

Recommended Posts

I need to put a date in this format to a string


this is what I have so far

#!/usr/bin/env python
#program will write HBF files for Windows side.
import datetime
import sys
import time

#declare strings
today =
fileLocation = sys.argv[1]
device = sys.argv[2]
filename = fileLocation+str(today)+'.hbf'

file = open(filename, 'w')

file.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
file.write(' <Date>'+str(today)+'</Date>\n')
file.write(' <Server>'+device+'</Server>\n')

I have it creating a date and converting to string but I need a diffrent format.. my simple searches have not helped much

Link to post
Share on other sites

got it

today = time.strftime('%Y%m%d%H%M%S')

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.