So I am using an API and I am getting the following updatedOn
response: "UpdatedOn": "/Date(1674542180860+0000)/"
.
I am using the following code to convert it to m/d/y
format:
if (!empty($data->Data->Shipment->UpdatedOn)):
$timestamp = preg_replace('/[^0-9+-]/', '', $data->Data->Shipment->UpdatedOn);
$date = new DateTime("@$timestamp");
$timestamp = $date->getTimestamp();
$parse_date = date('m/d/Y', $timestamp);
echo '<span>' . $parse_date . '</span>';
endif;
The issue is that it’s not outputting properly, so I need some help – Here is the output that I am receiving:
02/17/55034
I would like to output it in the following format: January 12th, 2023
.
Could anyone help me with my code?
2
Answers
In our decade timestamp is a 10 digit number
So this nember => "1674542180860" must be devide to 1000,
And if these two numbers "1674542180860" and "0000" must be added together, we should explod this string and sum two number,
I suggest you try this:
This is your favorite format to show date => "F dth Y"