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 Link to comment https://forums.phpfreaks.com/topic/9348-date-to-timestamp/ 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); Link to comment https://forums.phpfreaks.com/topic/9348-date-to-timestamp/#findComment-34465 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. Link to comment https://forums.phpfreaks.com/topic/9348-date-to-timestamp/#findComment-34536 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? Link to comment https://forums.phpfreaks.com/topic/9348-date-to-timestamp/#findComment-34640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.