1
Tue, 12 Jul 2016 07:44:24 GMT

is the output i am getting in the string . i need to convert this format to the UNIX time stamp but it is not in proper format the format of the given string is.

ddd, dd MMM yyyy HH':'mm':'ss 'GMT 

i want this date in PHP standard format for the UNIX time stamp conversion.

thank you

Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
Aniket Karne
  • 45
  • 1
  • 5

2 Answers2

1

Use strtotime to convert it into a UNIX time stamp.

Example:

$time = strtotime('Tue, 12 Jul 2016 07:44:24 GMT');
echo date('Y-m-d H:i:s', $time);

Make sure you also set your default timezone if you haven't done so at server level:

date_default_timezone_set('Europe/London');
Jamie Bicknell
  • 2,306
  • 17
  • 35
0

Your string Tue, 12 Jul 2016 07:44:24 GMT is actually a RFC 2822 formatted date. You can input run this string via strtotime() or DateTime, and then format as you wish.

If you wish to format back to RFC 2822 formated date, use r as format character, see date() function.

demo

Glavić
  • 42,781
  • 13
  • 77
  • 107