Adding time to date

This is the place for queries that don't fit in any of the other categories.

Adding time to date

Postby CoreCreation » Mon May 13, 2013 7:03 am

I am trying to make a python program where I imput the date AND time, and output the chrome filetime(not to be confused with windows filetime)

I found a python program to convert the chrome filetime into a time and date, but I have very little knowledge of regular python, and it's been awhile since I've used it so I have forgotten what I knew of it( I learnt python when I was using a program called blender 3d which is a 3d modeling / game creation program written in python and the game code was python based )

Here is the program to convert chrome filetime into date and time

Code: Select all
import datetime
date_string = datetime.datetime( 1601, 1, 1 ) + datetime.timedelta( microseconds=timestamp )


Where "timestamp" is is the filetime, which is the number of microseconds since 1601, 1, 1

An eg time stamp is 13012818612125800 which gives me 2013, 5, 12 07:50:12

I have been able to imput a date, but not time, and get the filetime. What I have so far is

Code: Select all
import datetime
date_string = datetime.datetime( 2013, 1, 1 ) - datetime.datetime( 1601, 1, 1 )
print date_string

# then multiply it by 86400000000


Where "2013, 1, 1" is an example date

The other problem is that I can't seem to multiply it by 864000000 in python, which is not a problem because I can do that on a calc

I would like some help on adding the time to the date, and if anyone could help, it would be greatly appreciated
CoreCreation
 
Posts: 2
Joined: Mon May 13, 2013 6:33 am

Re: Adding time to date

Postby rrashkin » Mon May 13, 2013 3:09 pm

From the library reference:
class datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])


So you can just add the hour, minute, second to your current parameters.
___________________
Bob Rashkin
User avatar
rrashkin
 
Posts: 35
Joined: Tue Feb 12, 2013 4:47 pm

Re: Adding time to date

Postby CoreCreation » Mon May 13, 2013 7:29 pm

Thank You So Much
CoreCreation
 
Posts: 2
Joined: Mon May 13, 2013 6:33 am


Return to General Coding Help

Who is online

Users browsing this forum: Baldyr, Google [Bot], snippsat, W3C [Linkcheck] and 6 guests