Date - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim



Calling Sequence







Calling Sequence


Date( d )

Date( t )

Date( year, month, day, hour, minute, second, millisecond )




Date; a Date object



Time ; a Time object



integer; the year (required)



integer; the number (1..12) of a month



integer; the number of a day within the month month



integer; the hour (0..24) of the day



integer; the minute within the hour



numeric; the second within the minute (may be fractional)



numeric; the millisecond within the second



timezone : string; the name of a time zone



The Date object represents a particular date and time in the Gregorian calendar. It represents a particular "view" of the a system UTC time, as represented by a Time object associated to the system UTC clock.


You can create a Date object by calling the Date constructor in several different ways.


Called without arguments, the Date() command returns the current date (and time of day) as reported by the system clock.


You can also pass an explicit UTC Time object t by calling the Date constructor in the form Date( t ).  This produces a Date object that represents the Time object t.


A Date object d can be passed to the Date constructor in the form Date( d ), producing a new Date object that represents the same moment in time as the original Date object d.  This is most useful when used in conjunction with the timezone= option to convert between different time zones.


The Date constructor also takes specific components: year, month, day, hour, minute, second and millisecond. These must be passed in the stated order, but all components after the year are optional in the sense that any initial sub-sequence of these may be passed with the values for omitted components being set to their default values. The default values for components after the year are all 0, except for hour, for which the default values is 12 (representing noon). However, you cannot specify any particular component without specifying all the components before it in the sequence. For example, to pass the hour component, you must also specify the year, month and day components (in that order) first.


The year value year must be in the range −9223372036854775808year9223372036854775807 on 64-bit platforms. On 32-bit platforms, the year is limited to the range −4294967296year4294967295.



Date objects support a number of methods.

Year  the year of the Date object

Month  the (numeric) month within the year

DayOfMonth  the (numeric) day of the month

HourOfDay  the hour of the day

Minute  the minute within the hour

Second  the seconds within the minute

TimeZone  the time zone of the Date object (by default, "UTC")

Precision  the precision of the Date object; normally the precision of the underlying Clock


The Year( d ) command returns the (integer) year of the Date object d.


The Month( d ) command returns the numeric month of the Date object d. This is an integer in the range 1 .. 12, with 1 denoting January, 2 denoting February, and so on.


The (integer) day of the month of the Date object d is returned by the command DayOfMonth( d ).  This is a positive integer, no larger than the last day of the month represented by d.


The HourOfDay( d ) command returns an integer in the range 0 .. 24 denoting the hour of the day represented by d (that is, a 24-hour clock). Note that an hour equal to 24 is equivalent to the 0th hour of the next day.


The minute of the hour represented by d is returned by the command Minute( d ).


The Second( d ) command returns the number of seconds after the minute of d.


The default time zone of a Date object is the local time zone. The TimeZone( d ) command returns the time zone of d, which may be set explicitly via the timezone = T option.


Since a Date object is just a particular view onto a moment in time, represented by a Time object stored within the Date, it has an associated precision, which is equal to the precision of the underlying clock. In this case, the clock is the SystemUTCClock. The Precision( d ) command returns the precision associated with the Date object d.


In addition to the command-like methods listed above, arithmetic with Date objects is supported, as are comparisons using the operators < and <=.


To compute the length of time between two dates represented by Date objects d1 and d2, use the expression d1 - d2. More generally, a rational combination of Date objects with coefficients that sum to 0 returns a unit expression of the time dimension.


Similarly, the midpoint between two Date objects d1 and d2 can be computed using the expression (d1 + d2) / 2. Again, more general rational combinations of Date objects with coefficient summing to 1 return a new Date object representing a generalized "average" of those dates.


Other combinations of Date objects return unevaluated.


Note that leap seconds are ignored in all date and time arithmetic.


Create the current date in the default time zone.


today<Date: 2024-03-01T04:27:09.383 GMT>


Extract various components of the object.










Create the current date in the local time zone.


today<Date: 2024-03-01T04:27:09 GMT>


Create a specific date representing 3:42am on July 1, 1967.


d<Date: 1967-07-01T03:42:00 GMT>


How long has it been since that moment?




Midnight (or any moment before 1am) can be specified either as the 24th hour of one day, or the 0th hour of the next day.


d1<Date: 1999-03-15T00:00:00 GMT>



d2<Date: 1999-03-15 GMT>





To compute the length of the Second World War (taken from the invasion of Poland, at 4:45am on Sept. 1, 1939 to the formal surrender of Japan at about 9am on Sept. 2, 1945), construct the Date objects corresponding to the beginning and end events of the war, and subtract.


d1<Date: 1939-09-01T04:45:00 Germany Time>



d2<Date: 1945-09-02T09:00:00 Japan Time>


The result is in milliseconds, since that is the precision of the UTC clock.




Use the convert command with the units option to convert the result to a more convenient form.









The Date command was introduced in Maple 2018.


For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also