birdie Posted May 8, 2006 Share Posted May 8, 2006 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 Quote Link to comment Share on other sites More sharing options...
.josh Posted May 8, 2006 Share Posted May 8, 2006 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); Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 9, 2006 Share Posted May 9, 2006 Or you can just use strtotime converts a valid date string to a UNIX timestamp. Quote Link to comment Share on other sites More sharing options...
birdie Posted May 9, 2006 Author Share Posted May 9, 2006 [!--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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.