-2
$time_str = '2013-09-03 03:29:11' ;

preg_match('/([0-9]+)-([0-9]+)-([0-9]+) (.*)/', $time_str, $matches);
$new_str = $matches[3] . '-' . $matches[1] . '-' . $matches[2] . ' ' . $matches[4];

When I check the value of $new_str I get

$new_str = 03-2013-09 03:29:11

but when I check the value of strtotime($new_str) I get an empty value for $str where $str = strtotime($new_str)

harshal
  • 10,252
  • 3
  • 18
  • 23
  • Is the format of `$new_str`correct as in MM-YYYY-DD, does it need to be in a different format for `strtotime`? – Lt_Shade Sep 05 '13 at 12:44
  • Actually I get this as output should use some date_format function to change it – harshal Sep 05 '13 at 12:45
  • It might help as the compiler might be confused with the format but I thought it would throw an exception. Look here http://stackoverflow.com/questions/2891937/strtotime-doesnt-work-with-dd-mm-yyyy-format – Lt_Shade Sep 05 '13 at 12:48

1 Answers1

0

to convert mm-dd-yyyy hh:mm string to a unix timestamp you can use strtotime

For more, findout reference here

Community
  • 1
  • 1
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57