Page 1 of 1

Convert m-d-Y to unix format

Posted: Fri Aug 15, 2008 8:23 pm
by GeXus
Does anyone know how to convert 08-15-2008 (m-d-Y) format into a unix timestamp for querying in php

Re: Convert m-d-Y to unix format

Posted: Fri Aug 15, 2008 8:25 pm
by Jade
Can't you use the maketime function and just convert it over? I'm pretty sure there's a function that can give you the date in unix format. Check the php manual: http://us.php.net/manual/en/function.date.php

It should be your new best friend!! :D

Re: Convert m-d-Y to unix format

Posted: Fri Aug 15, 2008 9:44 pm
by GeXus
Everything seems to be formatting a unix timestamp... I want to do the opposite.. take a formatted date and produce a unix timestamp.. can't seem to find it.

Re: Convert m-d-Y to unix format

Posted: Sat Aug 16, 2008 3:53 am
by baileylo
time returns unix time stamp, http://www.php.net/time

Re: Convert m-d-Y to unix format

Posted: Sat Aug 16, 2008 4:28 am
by EverLearning

Code: Select all

$date = "08-15-2008";
list($month, $day, $year) = explode("-", $date);
$date = mktime(0, 0, 0, $month, $day, $year);