Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php date from unix timestamp

Tags:

php

I have a unix timestapm in my database and i want it to be formated like this:

Y-m-dTH:i:s

T is just a symbol between date and time. If I convert it like this:

$t_date=date("Y-m-dTH:i:s", $row['date']);

I get something like this: 2012-03-05UTC06:06:49. The problem is that T is one of the parameters for formating date.

like image 973
Rafael Sedrakyan Avatar asked Mar 05 '12 06:03

Rafael Sedrakyan


2 Answers

<?php

echo $t_date=date("Y-m-d\TH:i:s", time());

?>

see http://codepad.org/SOSmzKvS

like image 55
sandeep Avatar answered Sep 29 '22 18:09

sandeep


If you're using PHP 5+, you can just use date("c") to get an ISO8601-format date (e.g. 2004-02-12T15:19:21+00:00).

http://us.php.net/manual/en/function.date.php

like image 32
Amber Avatar answered Sep 29 '22 16:09

Amber