A wanna format timestamps into a date format like so: 'Y-m-d H:i:s' => 'yyyy-mm-dd hh:ii:ss'
.
I tried to formatting with date function:
date('Y-m-d H:i:s', $comments[0]['created'])
and with DateTimeImmutable class:
$date = new DateTimeImmutable();
$acctualDate = $date->setTimestamp($comments[0]['created']);
$fomatedDate = $acctualDate->format('Y-m-d H:i:s');
but both give the same result.
I have this four date:
int(1679909217390)
int(1677169312318)
int(1676548411827)
int(1674216062741)
So i tried format with 'Y-m-d H:i:s', but the result is not right:
string(20) "55204-03-15 17:16:30"
string(20) "55117-05-19 20:31:58"
string(20) "55097-09-14 12:10:27"
string(20) "55023-10-18 17:25:41"
Then i tried format with this 'y-m-d H:i:s', but the result is still not right:
string(17) "04-03-15 17:16:30"
string(17) "17-05-19 20:31:58"
string(17) "97-09-14 12:10:27"
string(17) "23-10-18 17:25:41"
The datetime is almost correct, but the year is definitly not. I have not found solution for my problem.
So my question is how get datetime with the correct year, that fits in this format 'yyyy-mm-dd hh:ii:ss'
?
Thank you very much for your spending time, and your help.