Convert Date to Unix
Posted: Fri Jan 11, 2013 6:57 am
Hi I have the following code I think the date format is wrong.
I'm posting a date from a form as - 2013-01-10, before I post it to mysql I want to convert it to unix format.
The issue I'm having is the unix is incorrect when I convert it bacK
I'm still a beginner so need a bit of help to point me in the right direction
I'm posting a date from a form as - 2013-01-10, before I post it to mysql I want to convert it to unix format.
The issue I'm having is the unix is incorrect when I convert it bacK
I'm still a beginner so need a bit of help to point me in the right direction
Code: Select all
$wholedate = $_POST['duedate'];
$date_array = explode('.', $wholedate);
$test = mktime(0,0,0,$date_array[1],$date_array[2],$date_array[0]);
echo $test;
echo '<br>';
echo date('Y-m-d', $test); //Check if timestamp returns wanted date format