I am calling an API from where I am getting date /Date(1365004652303-0500)/, I don\'t understand what format this is. How is this date format called? I was not
Baba's answer is very helpful, yet it does not cover 3 cases I need:
This is what I use for getting the timestamp:
$date_string = '/Date(-594262800300+0100)/';
preg_match('/([+-]?\d+)([+-]\d{4})?/', $date_string, $matches);
$timestamp = $matches[1] / 1000;
$hours = $matches[2] * 36; // Get the seconds
return $timestamp + $hours;
Again, as Ghigo noted this is not correct if the offset contains minutes, but it works for my case.