Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

convert dates in Unix time format

10:10 am on Feb 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 26, 2005
votes: 0

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!

1:08 pm on Feb 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
votes: 0

Hi ktsirig,

I think the strtotime [uk.php.net] function is what you are looking for.


1:10 pm on Feb 11, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Jan 17, 2006
posts: 210
votes: 0

You should be able to use the mysql function UNIX_TIMESTAMP;

And do a simple update.

UPDATE myTable set myDate = UNIX_TIMESTAMP(myDate);

PLEASE NOTE: This is untested code, i suggest you backup everythin before you try any of my code =)