0

I am trying to parse the Unix timestamp in Laravel

/Date(1671847200000-0600)/

where 1671847200000 is the timestamp and this is -0600 offset (-06:00 i.e. -HH::mm)

expected output be like 2022-12-23 18:00:00

  • Unix timestamp contains no info about timezone: https://www.php.net/manual/en/function.time.php#:~:text=Unix%20timestamps%20do%20not%20contain%20any%20information%20with%20regards%20to%20any%20local%20timezone. – Techno Dec 16 '22 at 12:15
  • Thanks for the Information Is there is any default function to parse the timestamp to date – Ahamed Nadheem M Dec 16 '22 at 12:28
  • You mean like this?(check answer here)https://stackoverflow.com/questions/20617100/php-converting-integer-to-date-reverse-of-strtotime – Techno Dec 16 '22 at 12:28
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Mirdrack Dec 16 '22 at 12:56
  • Getting date as Date(1671847200000-0600) from third party api & I need to convert that values into a proper datetime, 1671847200000 - Unix timestamp -0600 this is offset – Ahamed Nadheem M Dec 16 '22 at 15:51
  • `1671847200000` == `2022-12-24T02:00:00.000Z`, which is the same as `2022-12-23T20:00:00.000-06:00`. The only way you'd get it to be `18:00` is if you used an offset of `-08:00`. – Matt Johnson-Pint Dec 16 '22 at 23:40
  • Note that in this format you gave, the timestamp and offset are independent. The timestamp is at UTC, and the offset is extra information. Contrast that with the standard ISO 8601 format, where the date and time are *already* adjusted by the amount of the offset. – Matt Johnson-Pint Dec 16 '22 at 23:42

0 Answers0