General Community > Scripting Help
Converting date/time into a Unix timestamp
Shadow:
Is there a way to convert 10 Oct 03 2052 into time measured in the number of seconds since the Unix Epoch?
Thanks,
Shadow
Spaceman-Spiff:
http://www.4webhelp.net/us/timestamp.php
writeto:
The only way I know is it have an array storing the number of seconds in a month. Having a const variable with the seconds in an hour, minute, day and a year.
Then :
Adding all the number of years since January 1, 1970 * 31536000.
Adding all the month predessing current using the array.
Adding all the days before current * 86400.
Adding the hours, minutes and seconds.
Checking for leap year for everyyear and adding 86400seconds for everyyear that was a leap year.
I do not know an easier way. If you tell me the language you need this in AND you can not do it yourself I can see if I have the time to write this for you.
Andrew
Spaceman-Spiff:
if it's php that you want, then use the function mktime
writeto:
Sorry I wasn't thinking this is a php scripting forum. If you are using PHP then combining mktime and date will easily accomplish this. There are also easier way to do this in various languages including C++, Basic... I was just providing a catch all.
Navigation
[0] Message Index
[#] Next page
Go to full version