1

I'm trying to convert the date format but strtotime does not work. I'm using in date type in mysql database.

What I'm trying ?

$d_date = $order_info['shipping_delivery_date'];
$delivery_date_formate = date("d M Y", strtotime($d_date));

$replace = array(
 'delivery_date'  => $delivery_date_formate,
);

But this code return me this date 31 Dec 1969 instead of saved date (in database). I checked date is properly retrieving from database in this $order_info['shipping_delivery_date'] index.

I also searched about date. This Accepted Answer properly working on my loacalhost with following code.

$d = array( 'dt' => '2010-03-21');
$originalDate = $d['dt'];
$newDate = date("d M Y", strtotime($originalDate));
echo $newDate;  

I'm using same trick but it does not work using above code. Can any one please guide me.

Community
  • 1
  • 1
Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68

2 Answers2

1

Try with this

$d = array( 'dt' => '2010-03-21');
$originalDate = $d['dt'];
$newDate = date("d M Y", strtotime($originalDate));
 echo $newDate; 
Drone
  • 1,114
  • 1
  • 12
  • 31
1

According to http://php.net/manual/en/function.strtotime.php

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. If, however, the year is given in a two digit format and the separator is a dash (-, the date string is parsed as y-m-d.

Mahmoud Tantawy
  • 713
  • 5
  • 12