Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert ISO 8601 to unixtimestamp

How can I convert 2012-01-18T11:45:00+01:00 (ISO 8601) to 1326883500 (unixtimestamp) in PHP?

like image 634
Codler Avatar asked Jan 18 '12 10:01

Codler


People also ask

How do I convert ISO to timestamp?

Use the getTime() method to convert an ISO date to a timestamp, e.g. new Date(isoStr). getTime() . The getTime method returns the number of milliseconds since the Unix Epoch and always uses UTC for time representation. Copied!

How do I convert ISO to date?

Use the Date() constructor to convert an ISO string to a date object, e.g. new Date('2023-07-21T09:35:31.820Z') . The Date() constructor will easily parse the ISO 8601 string and will return a Date object. Copied! We used the Date() constructor to create a Date object from an ISO string.

What is the timezone of ISO 8601?

Time zones in ISO 8601 are represented as local time (with the location unspecified), as UTC, or as an offset from UTC.


1 Answers

echo date("U",strtotime('2012-01-18T11:45:00+01:00')); 
like image 96
k102 Avatar answered Sep 21 '22 01:09

k102