time

toc
<mm:time> The time tag can be used for all kind of manipulations regarding times.
see alsolocale
attributes
  • time
    The time attribute specifies the time to be used, this can be done in multiple ways, in order of preference: 1) If the `inputformat' attribute is used, this is used to parse the content of the `time' attribute, one can define `human readable format' like this. 2) Specify the time in seconds from EPOCH (this is the way how MMBase handles times). 3) By using keywords, such as: yesterday, tomorrow, today, now.
  • inputformat
    The inputformat attribute cat be used to specify how the time attribute should be parsed. The comprehensive syntax for this attribute can be found at http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html . Notice that if times have the following form they will be parsed automatically, and this attribute can be omitted: yyyy/MM/dd hh:mm:ss, yyyy/MM/dd, and hh:mm:ss.
  • offset
    The offset attribute can be used to change the time specified with the time attribute. The offset is expressed in seconds.
  • format

    The format attribute specifies how to display the time. If the format attribute is not used the time will be displayed in seconds from EPOCH. The syntax of the format attribute is identical to the syntax of the inputformat attribute. Instead of using the format attribute you can also use the MMBase formatter taglib.

    Alternatively, you can also symbolically indicate how verbosely the date and or time must be presented. You do this by starting this string with a semicolon (:) followed by one or two constants separated by a dot. The first constant is for the date part, the second for the time part. Both these constants can take the following values `FULL', `LONG', `MEDIUM' and `SHORT'.


    y Only the year part of the specified time
    e Day of the week as in integer (7=Saturday, 1=Sunday). This is not done by SimpleDateFormat, because it doesn't support that (Don't ask me why).
    rfc822 Date and time in the format specified in the RFC822, see http://www.faqs.org/rfcs/rfc822.html , which can be handy when creating f.e. RSS-feeds http://blogs.law.harvard.edu/tech/rss that require this format.
    :FULL.FULL Fully specified date and time formatted according to the present Locale.
    :MEDIUM Mediumly verbosely specified localized date.
    MM/dd/yyyy Gives e.g. 11/20/2003.
  • precision (since: MMBase-1.7)

    Specifies the `precision' of the produced time. Times are rounded off to the beginning of the specified unit. This can have several purposes. One of them being that such a rounded of time can be used in queries, without resulting to much different queries ('now' with a precision of minutes, will e.g. result a new `now' only once a minute, so a query with a constraint containing `now' has to be redone only once a minute (in stead of every second)).

    Since MMBase-1.8.2, if the value of this attribute does not evaluate to one of the known units, it will fall back by prefixing with 'duration +' and then feeding it to the MMBase date parser. The specified time will be divided and multiplied by the thusly specified number of seconds since 1970. Specifying e.g. '3 minute' will effectively allow you to specify a preciesion of 3 minutes like this.


    seconds This is the default. Times are produced to `second' accuracy (the maximum in MMBase).
    minutes
    hours
    days
    weeks
    months
    years
    3 minute
    30 second
  • timezone (since: MMBase-1.7)
    The time-zone for which the time must be shown. Defaults to the server's time-zone.
    CETCentral European Time
    GMTGreenwich Mean Time
writer attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
writerreferrer attributes
example 1
      <mm:time format="yyyy/MM/dd" /> generates 2002/04/21
    
example 2
<font color="red">A few cool datetime results:</font><br />
<mm:import id="langs" vartype="list">es,de,it,nl,zh,ja,ar,el,he,ru</mm:import>
<mm:aliaslist referid="langs">
<mm:locale language="$_"><mm:time time="now" format=":FULL.FULL" /></mm:locale><br />
</mm:aliaslist>
<font color="red">Only a date:</font><br />
<mm:locale language="fr"><mm:time time="now" format=":LONG" /></mm:locale><br />
<font color="red">Only a time:</font><br />
<mm:locale language="nl"><mm:time time="now" format=":.MEDIUM" /></mm:locale><br />
<font color="red">SimpleDateFormat:</font><br />
<mm:locale language="pl">:<mm:time time="now" format="MMMM yyyy" /></mm:locale><br />
A few cool datetime results:
martes 21 de mayo de 2013 12H07' CEST
Dienstag, 21. Mai 2013 12:07 Uhr MESZ
martedì 21 maggio 2013 12.07.27 CEST
dinsdag 21 mei 2013 12:07:27 uur CEST
2013年5月21日 星期二 下午12时07分27秒 CEST
2013年5月21日 12時07分27秒 CEST
21 مايو, 2013 CEST 12:07:27 م
Τρίτη, 21 Μάϊος 2013 12:07:27 μμ CEST
12:07:27 CEST יום שלישי 21 מאי 2013
21 Май 2013 г. 12:07:27 CEST
Only a date:
21 mai 2013
Only a time:
12:07:27
SimpleDateFormat:
:maj 2013
example 3
keywords:<br />
<mm:time time="tomorrow" format="yyyy/MM/dd HH:mm:ss" /><br />
<mm:time time="saturday" format=":FULL" /><br />
<mm:time time="july" format=":SHORT" /><br />
human readable time indication: <br />
<mm:time time="2002/05/27" format=":FULL"/><br />
<mm:time time="12:34:10"   format=":.FULL" /><br />
<mm:time time="2002/05/27 12:34:10" format=":FULL.FULL" /><br />
Can also override the parsing format: <br />
<mm:time time="2000-11-01" inputformat="y-M-d" format=":FULL"/>
keywords:
2013/05/22 00:00:00
Saturday, May 25, 2013
7/1/13
human readable time indication:
Monday, May 27, 2002
12:34:10 PM CET
Monday, May 27, 2002 12:34:10 PM CEST
Can also override the parsing format:
Wednesday, November 1, 2000
example 4
This example adds 3 days (259200 seconds) to the given time.<br />
<mm:time time="now" offset="259200" format="EEEE d MMM yy" />
This example adds 3 days (259200 seconds) to the given time.
Friday 24 May 13
example 5
Display yesterday and save it as a jspvar. When no vartype 
is given, the formatted time is stored as String:<br />
<mm:time time="yesterday" format="EEEE d MMMM" 
         jspvar="yesterday" write="true" ><br />
And tomorrow too.
<mm:time time="tomorrow" format="EEEE d MMMM" jspvar="tomorrow"><br />
Use the jspvars in your page:<br />
I want to see all movies between
<%="" + yesterday%> and <%=tomorrow%>.<br />
</mm:time>
</mm:time>
<p>
</p>
When using vartype='date', the actual 'date' object is passed 
around, and can be reused for date-manipulations.
<mm:time id="nice_time" time="2002/04/05 12:34:56"  
         format=":LONG.LONG"  vartype="date" /><br />
Reusing the taglib variable 'nice_time':
<mm:write referid="nice_time" /><br />
<mm:time referid="nice_time" format=":FULL"  /><br />
<mm:time referid="nice_time" format=":FULL.FULL" 
         precision="hours"  /><br />
<mm:time referid="nice_time" vartype="date" jspvar="date">
  <%= date.getClass().getName() %>
</mm:time>
<hr />
<mm:time id="other_time" time="2002/04/05 12:34:56"  
         format=":LONG"   /><br />
<mm:write referid="other_time" /><br />
<mm:write referid="other_time" jspvar="date2">
  <%= date2.getClass().getName() %>
</mm:write>
Display yesterday and save it as a jspvar. When no vartype is given, the formatted time is stored as String:
Monday 20 May
And tomorrow too.
Use the jspvars in your page:
I want to see all movies between Monday 20 May and Wednesday 22 May.

When using vartype='date', the actual 'date' object is passed around, and can be reused for date-manipulations. 1018002896
Reusing the taglib variable 'nice_time': 1018002896
Friday, April 5, 2002
Friday, April 5, 2002 12:00:00 PM CEST
java.util.Date
April 5, 2002
April 5, 2002
java.lang.String