Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML time tag - correct date format

Tags:

html

time

tags

I am wanting to use the correct format and standards to put the time tag in my html document.

Is this the correct way to do it?

<time datetime="2014-03-26T12:48:42.733Z">26/03/2014</time>

Thanks

like image 830
Joe Avatar asked Oct 16 '25 13:10

Joe


2 Answers

The Format is YYYY-MM-DDThh:mm:ssTZD

The date or time being specified. Explanation of components:

YYYY - year (e.g. 2011)
MM - month (e.g. 01 for January)
DD - day of the month (e.g. 08)
T - a required separator if time is also specified
hh - hour (e.g. 22 for 10.00pm)
mm - minutes (e.g. 55)
ss - seconds (e.g. 03)
TZD - Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)

So Yes

Source

like image 143
schnawel007 Avatar answered Oct 19 '25 04:10

schnawel007


The time element defined in HTML5 must specify a time or date or both, or other applicable designation in a specific machine-readable format, as described in the draft. This designation may appear as the element content, e.g.

<time>2014-03-26</time>

If it does not (typically, when the content specifies a date or time in human-readable form in some language), the machine-readable designation must appear as the value of the datetime attribute, e.g.

<time datetime="2014-03-26">26/03/2014</time>

The notation in the question is not adequate, as the value of the attribute must be “a representation of the element's contents in a machine-readable format”, and a date and time denotation, down to milliseconds, can hardly be said to represent a date.

Note: There is no evidence of browsers or search engines making any use of time markup, so such markup is only potentially useful.

like image 35
Jukka K. Korpela Avatar answered Oct 19 '25 04:10

Jukka K. Korpela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!