This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Time


We frequently describe events in our daily communications. As humans, we can easily interpret statements such as 'would you like to hang out tonight?' or 'my birthday is 1/7/81.' These statements are ambiguous on a couple of levels. First, 'today' is constantly changing. An event taking place 'today' quickly becomes yesterday's news. The second example even gives us humans difficulty. Is the date July 1st, 1981 or January 7th 1981?

HTML5 provides us with a tag to explicitly convey dates and times. The tag, as with most HTML tags, is appropriately named:

  • <time>

The <time> tag has an attribute called datetime. The datetime attribute takes a specifically formatted string:

YYYY-MM-DDTHH:MMTZO
YYYY = four digit year
MM = two digit month, zero padded if necessary
DD = two digit day, zero padded if necessary
T = time separator, do not change
HH = hour, 24 hour (e.g. 13 = 1PM), zero padded if necessary
MM = minute, two digits
TZO = timezone offset, +/- 23:59 (typically whole hour offset)

An example of a specific event would be August, 21st, 1999 355PM GMT -8:

<time datetime="1999-08-21T15:55-08">

The <time> tag also has a boolean attribute called pubdate. When pubdate is present in a <time> tag, the event is taken to be the publishing date of the parent element (such as an <article>.)

The time format adheres to a convention, designated by the International Standards Organization, called ISO 8601:

The standard organizes the data so the largest temporal term (the year) appears first in the data string and progresses to the smallest term (the second). It also provides for a standardized method of communicating time-based information across time zones by attaching an offset to Coordinated Universal Time (UTC).

Discussion Questions

Please answer the following questions in the discussion section for this task.

  • What do you see as beneficial about HTML5 adopting the ISO 8601 date format? I.e. How is having the date format starting with year beneficial?
  • How do you normally write dates? What punctuation do you use between date elements?
  • What are some other classification or designation systems where the largest components preceed the smaller ones?

Extra Credit

The datetime attribute assumes that dates are relative to the Gregorian calendar (Inter gravissimas). Describe one or more alternative calendars including a brief history, merits, as well as shortcomings of the each calendar.

Task Discussion


  • EcologicalHumanist   Jan. 19, 2014, 10:37 a.m.

    The advantage of writing dates this way is standardization and compatability.

    I usually writed dates like this: 1/18/2014.

    Other forms of notation that proceed from largest to smallest? file names.

  • Karam   Oct. 10, 2013, 4:03 p.m.

    The benefits of writing the date like 2013-10-8 is that people from all over the world know the exact date you are talking about. In Europe for example, people would often write 7-8-2013, whereas in North America the same date is written 8-7-2013.

    As you can see, this may be confusing at times so starting the date with the year, month, and day helps us in avoiding this unncessary confusion.

  • bryanwoodsmall   July 7, 2013, 6:25 p.m.
    • What do you see as beneficial about HTML5 adopting the ISO 8601 date format? I.e. How is having the date format starting with year beneficial?

    Putting the year first and going from largest to smallest would make it easier to convert the entire string to a number representing the exact time and date.  Also, it is easy to remember the order

    • How do you normally write dates? What punctuation do you use between date elements?

    I write numeric year, then 3 letter abbr. of the month, then the day.  I put no punctuation between the elements.  For example: 7 Jul 2013

    • What are some other classification or designation systems where the largest components preceed the smaller ones?

    Taxonomy for plants and animals.  Latitude and longitued (degrees, minutes, seconds).

  • Cinder   May 25, 2013, 1:01 p.m.

    What do you see as beneficial about HTML5 adopting the ISO 8601 date format? I.e. How is having the date format starting with year beneficial?

    It allows users to easily see how recent something is. 

    How do you normally write dates? What punctuation do you use between date elements?

    I normally write dates like this: 5/25/13 or 5/25/2013

    What are some other classification or designation systems where the largest components preceed the smaller ones?

    Isn't this how everything usually works in HTML? Correct me if I'm wrong. Otherwise, I don't know.

  • zoki   April 23, 2013, 10:47 a.m.

     

    • What do you see as beneficial about HTML5 adopting the ISO 8601 date format? I.e. How is having the date format starting with year beneficial?

    Está bien que exista un método preestablecido. Empezaremos escirbiendo desde el año hacia unidades de tiempo más pequeñas. Es conveniente ver el estándar ya que no todas las combinaciones están permitidas.

    • How do you normally write dates? What punctuation do you use between date elements?

    Yo normalmente escribo una fecha así: 18/11/1982 13:45. Lo que sería dd/mm/yyyy hh:mm, pero habrá que adaptarse a la otra manera.

    • What are some other classification or designation systems where the largest components preceed the smaller ones?

    Nuestro propio sistema numérico. En una cifra nuestra aparece primero una decena que la unidad, por poner un ejemplo. Pensándolo así, no resulta tan raro aplicar el formato de fecha sugerido.

  • Anonym   June 24, 2012, 4:27 p.m.

    awesome

    I didnt know about time tag

    really cool and fun :D

  • Pau Company   May 31, 2012, 11:32 a.m.

    Bueno, en realidad la ventaja que veo es poder utilizar un formato estandar, pero, los latinos, siempre ponemos en primer lugar el dia, luego el mes,  y por ultimo el año, con lo cual, pueden surgir problemas. de echo en diferentes articulos, parece que se suprime el uso de <time> <daretime> y <pubdate>, fuente y posibles soluciones en:

     

    http://jorgedelcasar.com/adios-time-datetime-y-pubdate-en-html5/

    http://html5doctor.com/time-and-data-element/

    http://www.brucelawson.co.uk/2011/goodbye-html5-time-hello-data/

     

    Referente a los diferentes tipos de calendario, mando un link de la wiki, ya que asi lo pongo al alcance de todos, termino los requisitos del ejercicio y me ahorro tiempo de teclear y dedicar al siguiente ejercicio, que ya tengo casi todos terminados.

     

    Calendario Gregoriano:

    http://es.wikipedia.org/wiki/Calendario_gregoriano

    Calendario chino:

    http://es.wikipedia.org/wiki/Calendario_chino

    Calendario Musulman:

    http://es.wikipedia.org/wiki/Calendario_musulm%C3%A1n