Why does DateTime add a T separator to the timestamp?

My code is:

print DateTime->now;

Answer:

2012-08-17T20: 16: 37

Why does T exist? Is there an option that I forgot?

+5
source share
4 answers

TIt is a standard (ISO 8601) method for delimiting time. To use a different format, consider using strftimeor format_cldr.

For example, use space instead DateTime->now->format_cldr("YYYY-MM-dd hh:mm:ss").

+13
source

The object string DateTimeuses the ISO 8601 format if you did not specify a formatter in the constructor. See Formatting and Gating in documents. Method iso8601:

sub iso8601 { join 'T', $_[0]->ymd('-'), $_[0]->hms(':') }
+4
source

This default DateTime output format produces ISO-8601. If you want something else, you need to use methods strftimeor format_cldror one of the modules DateTime::Format::*to output a different format, for example:

print DateTime->now->format_cldr("YYYY-MM-dd hh:mm:ss");
+2
source

this iso standard for date and time, see http://en.wikipedia.org/wiki/ISO_8601

see, for example, How do you read system time and date in Perl? to discuss the date / time of reading in format.

0
source

All Articles