...

View Full Version : Convert date (DD/MM/YYYY) into timestamp



tomharto
09-13-2011, 12:10 AM
I need to convert a date in the format dd/mm/yyyy (date format got from jQuery datepicker) and i need to convert it to a timestamp.

I tried
time($_POST['datepicker']);

but that didnt work, how would i do this?

BluePanther
09-13-2011, 12:16 AM
http://php.net/manual/en/function.strtotime.php

strtotime($_POST['datepicker']) should return a valid timestamp I think. I would check it though.

Easy way to check:


// Both should echo the same thing
echo $_POST['datepicker']."\n";
echo date("d/m/Y", strtotime($_POST['datepicker']));

tomharto
09-13-2011, 12:39 AM
Ahh, that worked, thank you :)

BluePanther
09-13-2011, 01:18 AM
No problem :). The manual has a full list of time/date formats strtotime will accept, just as an FYI :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum