I am building an email which will be used via a web form to transmit data to a mailbox. I am looking to timestamp the XML portion of the email using ISO 8601 format. I need to get the time the email is sent then convert it all using PHP. Any ideas?
date('c')
will output the current server time in iso8601. If you're looking to read in a date, you can pass a timestamp into the function like this
date('c',strtotime('January 4th 2001 4:30pm'))
where the argument for strtotime is just about any english readable text representation of a date.
which php version do you use?
date('c');
has been added in php5.
The format Y-m-d\TH:i:sO
is the same as c
. Since PHP 5.1.1 there is the constant DATE_ISO8601
holding this value.