-2

I get the date in the variable date as

    $date = "<?php echo $projects->dob;?>" ;  //where let dob=2013-01-12

I want to convert this into Jan 2013 format. How to convert in php?

user3702622
  • 21
  • 3
  • 8
  • 1
    Did you er, skip the [PHP Manual page on Dates](http://www.php.net/manual/en/function.date.php) whilst searching for how to format dates in PHP? – SubjectCurio Jun 26 '14 at 10:20

4 Answers4

2

do:

echo date('M Y', strtotime($your_date));

see: Date Formats

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
1
$dob = '2013-01-12';
echo date('M Y', strtotime($dob));

$date = date('M Y', strtotime($projects->dob));

Example:

https://ideone.com/tdJl8O

Jorge Faianca
  • 791
  • 5
  • 11
0
$timestamp = strtotime("2013-01-12");
$formatted = date("M Y", $timestamp);

Demo: http://codepad.org/Lw2eEq6Q

Peter
  • 16,453
  • 8
  • 51
  • 77
0

echo $date = date("M Y",strtotime($projects->dob)) ;

Rakesh Singh
  • 1,250
  • 9
  • 8