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.

Discusión de la Tarea


  • EcologicalHumanist   19 de enero de 2014 a las 10:37

    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   10 de octubre de 2013 a las 16:03

    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   7 de julio de 2013 a las 18:25
    • 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   25 de mayo de 2013 a las 13:01

    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   23 de abril de 2013 a las 10:47

     

    • 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.

  • Anónimo   24 de junio de 2012 a las 16:27

    awesome

    I didnt know about time tag

    really cool and fun :D

  • Pau Company   31 de mayo de 2012 a las 11:32

    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