-2

I'm trying to convert 1540621628 value which is coming from Database date_created field. I want this to be converted to proper date.

What i tried:

date("m/d/Y H:i:s", strtotime($symptom[ 'date_created' ]));

But it's printing 12/31/1969 19:00:00 which isn't valid value because i converted the 1540621628 in https://www.epochconverter.com/ and it gives proper date i.e

GMT: Saturday, October 27, 2018 7:06:34.154 AM Your time zone: Saturday, October 27, 2018 12:06:34.154 PM GMT+05:00

Nick
  • 138,499
  • 22
  • 57
  • 95
Imad uddin
  • 147
  • 1
  • 2
  • 11

1 Answers1

2

You shouldn't use strtotime on a timestamp, just pass the timestamp directly to date:

$symptom[ 'date_created' ] = 1540621628 ;
echo date("m/d/Y H:i:s", $symptom[ 'date_created' ]);

Output

10/27/2018 08:27:08
Nick
  • 138,499
  • 22
  • 57
  • 95