-2

I need help with this specific piece of code. How can I get php strtotime to recognize 20140802T00:00:00 as a proper time string?

$new_exp = date('M-d-y',strtotime($condat['_CouponExpiration']));
echo $conDat['_CouponExpiration'] . ' ' .$new_exp;

// 20140802T00:00:00 Jan-01-70
// $newexp should return "Aug-02-14"
themerlinproject
  • 3,542
  • 5
  • 37
  • 55

1 Answers1

1

Use str_replace to replace the "T" with a space, and that should solve the problem:

<?
  $D1="20140802T00:00:00";
  $D2=str_replace("T", " ", $D1);
  print $D1 . "\n";
  print $D2 . "\n";
  print strtotime($D2) . "\n";
  print date('M-d-y', strtotime($D2)) . "\n";  
?>

produces:

20140802T00:00:00
20140802 00:00:00
1406952000
Aug-02-14
mti2935
  • 11,465
  • 3
  • 29
  • 33