unix-timestamp from - Convert String To date in PHP

strtotime get (9)

Try this:

$new_date=date('d-m-Y', strtotime($date));

How can I convert this string 05/Feb/2010:14:00:01 to unixtime ?

Simple exploding should do the trick:

$monthNamesToInt = array('Jan'=>1,'Feb'=>2, 'Mar'=>3 /*, [...]*/ );
$datetime = '05/Feb/2010:14:00:01';
list($date,$hour,$minute,$second) = explode(':',$datetime);
list($day,$month,$year) = explode('/',$date);

$unixtime = mktime((int)$hour, (int)$minute, (int)$second, $monthNamesToInt[$month], (int)$day, (int)$year);

If you're up for it, use the DateTime class

$dr= date_create_from_format('d/M/Y:H:i:s', $d);
echo $dr->format('Y-m-d H:i:s');

here you get date string, give format specifier in ->format() according to format needed

Use the strtotime function:


 $date = "25 december 2009";
 $my_date = date('m/d/y', strtotime($date));
 echo $my_date;

If it's a string that you trust meaning that you have checked it before hand then the following would also work.

$date = new DateTime('2015-03-27');


<script type="text/javascript">
var yourstring = 'Your Name'
var lowercase = yourstring.toLowerCase();
document.write('original string:<b> ' + yourstring + '</b><br>');
document.write('converted sting <b>' + lowercase + '</b>');

try it on


php string unix-timestamp