My SQL server uses the mm/dd/yyyy
date format, but the date picker that I have implemented using jQuery gives the date format as dd/mm/yyyy
.
So I coded this to check if the given input is in the format of mm/dd/yyyy
, but it evaluates to true no matter which format the date input is given in. PHP code is,
$Temp = DateTime::createFromFormat('d/m/Y', $StartsOn);
if($Temp)
$Temp->format('m/d/Y');
I need to convert to mm/dd/yyyy
format only if the input is in dd/mm/yyyy
. So please tell me what is the logical error that I have made in my code.
xx-xx-xxxx
orxx/xx/xxxx
, PHP treats a-
separator as US format, a/
separator as European format - as documented, php.net/manual/en/datetime.formats.date.php