schemacs
schemacs

Reputation: 2891

How to escape 'T' in django's date template tag

I want to use DATETIME_FORMAT = 'Y-n-jTH:i:s' to display 2014-4-26T16:19:43, But the result is 2014-4-26CST16:19:43, How to Escape T(which is for timezone)? docs

Upvotes: 3

Views: 1161

Answers (3)

schemacs
schemacs

Reputation: 2891

'Y-n-j\TH:i:s' works. See echo date('l jS \of F Y h:i:s A'); on this reference.

Upvotes: 5

Daniel Roseman
Daniel Roseman

Reputation: 599926

You should just use the c value on its own, which matches the standard ISO format - which is what your desired format is.

Upvotes: 0

Dan Loewenherz
Dan Loewenherz

Reputation: 11253

Standard datetime formatting requires preformatted characters to be surrounded in quotes. Try this:

DATETIME_FORMAT = "Y-n-j'T'H:i:s"

Upvotes: 0

Related Questions