Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   convert dates in Unix time format (http://www.programmingforums.org/showthread.php?t=12554)

ktsirig Feb 11th, 2007 5:47 AM

convert dates in Unix time format
 
Hello all,
I have around 900 dates in the format of DD-MM-YYYY and I want to convert them in Unix time format...
Is there a way to do this? I was thinking of passing them into an array, and then, for each date, I would use the function date() I suppose and get the Unix time format of them... But I don't know the way to do it...

So, for instance, if you have:
$date_to_format='05-10-2006' , how would I get the Unix timestamp?

Thank you in advance!

jasper_ferrer Feb 11th, 2007 9:55 AM

you would have to extract the year, month and day values of the date then use mktime().

grimpirate Feb 11th, 2007 9:20 PM

[PHP]$unix_timestamp = mktime(date("G"), date("i"), date("s"), substr($date_to_format, 0, 2), substr($date_to_format, 3, 2), substr($date_to_format, 6), date("I"));[/PHP]Hope that helps.


All times are GMT -5. The time now is 1:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC