I am using datePicker for date selection in the front end. I have shown date like this:
September,30 2012
But when I receive it in PHP and try to convert it into date format, it generates wrong date.
$var = date('Y-m-d', strtotime('September,30 2012'));
The above gives me 1970/01/01.
Just remove the ,
from the datepicker's output..And it'll be fine
$var = date('Y-m-d', strtotime('September 30 2012'));
gives you 2012-09-30
And to remove comma,use
$daf = 'September 30 2012';
echo str_replace(',','',$daf); // gives September 30 2012
i think its the comma that is doing that... removing comma gives u correct answer.. try this
echo date('Y-m-d',strtotime('September 30 2012'));
This may work
$var = date('F d y', strtotime('September 30 2012'));
just remove the comma and you get the solution
<?php
$date = 'September,30 2012';
echo $var = date('Y-m-d', strtotime('September-30-2012')); //this gave me 1970/01/01
or just remove the dash it works in both scenario