Jump to content

Archived

This topic is now archived and is closed to further replies.

birdie

date to timestamp

Recommended Posts

hi, i know this is probably a newbie question but i usually do timestamp => date.

say i have a variable,

$var = "Mar 5, 2003";

how would i be able to convert this to a unix timestamp? would i use strtotime or something?

thanks for your help, its greatly appreciated

Share this post


Link to post
Share on other sites
if you pull out the day month and year from that string, you can do it like so:

$timestamp = mktime(0,0,0,$month, $day,$year);

edit: btw those first 3 zeros are for hours, minutes and seconds

$timestamp = mktime($hour,$minute,$second,$month,$day,$year);

Share this post


Link to post
Share on other sites
Or you can just use strtotime converts a valid date string to a UNIX timestamp.

Share this post


Link to post
Share on other sites
[!--quoteo(post=372528:date=May 9 2006, 09:27 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 9 2006, 09:27 AM) [snapback]372528[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Or you can just use strtotime converts a valid date string to a UNIX timestamp.
[/quote]

thanks violent, helps alot. Wildteen, are u sure that would work with any random date?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.