Can anyone tell me what kind of date is this format?
2013-09-17T05:59:00+01:00
I have in the database a field of type timestamp or date. How to convert the value of it to this format using PHP?
Can anyone tell me what kind of date is this format?
2013-09-17T05:59:00+01:00
I have in the database a field of type timestamp or date. How to convert the value of it to this format using PHP?
You can get a date in this format, from a record of your MySQL
database, like this:
echo date("Y-m-d\TH:m:sP", strtotime($db_date));
Where the variable $db_date
is the field you are fetching from your database (regardless of type date or timestamp ), and the output is exactly that you put in your question.
In the PHP
documentation for date()
you find all these formats that I I used the first parameter. In the second parameter, I just converted your date to Unix timestamp via strtotime()
.
As well as the rray quoted here , a more simplified way is to use the c
parameter, which already returns a date in the format ISO 8601
:
echo date("c", strtotime($db_date));