tags:

views:

43

answers:

3

I need to create a date in this xsd format: "2001-10-26T21:32:52" but when I use the date function in php it replaces "T" with the Timezone (which it is supposed to do). This is the command I'm using:

$time = date("y-m-dTH:i:s", time());

Which produces: '10-02-13EST10:21:03'

How do I get it replace "EST" with just "T"?

Thanks.

+4  A: 

Your format shoule be : "c"

$time = date("c", time());

From PHP manual:

Format Descriptions                        Example
c      ISO 8601 date (added in PHP 5)   2004-02-12T15:19:21+00:00
Daok
This did it. Thanks for the format description too.
motboys
A: 

use it like this

<?php
 $time = time(); 
 $time = date( "y-m-d",$time )."T".date( "H:i:s", $time );
?>
GeekTantra
A: 

In addition to what Daok said, if you need to insert a character which should not be interpreted, precede it with a backslash:

$time = date("y-m-d\TH:i:s", time());
kemp