Rafael Sedrakyan
Rafael Sedrakyan

Reputation: 2629

php date from unix timestamp

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.

Upvotes: 5

Views: 4195

Answers (2)

Amber
Amber

Reputation: 527378

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

Upvotes: 1

sandeep
sandeep

Reputation: 2234

<?php

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

?>

see http://codepad.org/SOSmzKvS

Upvotes: 8

Related Questions