Forum Moderators: coopster
I'm trying to add a date picker to a new form that submits the date in this format: mm/dd/yyyy. I'm having trouble figuring out how to convert that format to the epoch timestamp.
So far all attempts with using mktime has resulted in me getting todays epoch timestamp added to the database field regardless of what date is entered.
Here's a quick example of the code that produced that incorrect result:
$epochhold = (_$POST['date']);
$epoch = mktime(0,0,0,$epochhold);
Anyone have any ideas?
Thanks in advance!
unix timestamps and the epoch can give you fits sometimes so be careful and read the warnings on the manual pages for the date/time functions that you use, including mktime [php.net].
The problem you are having here is that (besides the syntax error in your $_POST variable declaration) is that you are not separating the arguments of your
$epochholdvariable into mm, dd, yyyy as the function expects. You are trying to pass the entire string of 'mm/dd/yyyy' as the month argument of mktime.