WolframLang: Date Time

By Xah Lee. Date: . Last updated: .

Date Object

DateObject[]

return current local date

DateObject

DateObject[  ]

(* sample value
DateObject[{2023, 12, 5, 10, 47, 43.1793343`9.387850814365704}, Instant, Gregorian, -8.]
 *)
DateObject[{year, month, date, hour, minutes, seconds}]
  • return a date object.
  • The arguments are all integers.
  • Any of the smaller time unit can be omitted.
Now

return a DateObject of current date and time.

Now

Now
(* DateObject[{2022, 7, 17, 13, 51, 20.2956073`9.059976985734098}, Instant, Gregorian, -7.] *)

Date String

DateString[]

return current datetime string.

DateString

DateString[ ]
(* Mon 22 Nov 2021 21:25:08 *)
DateString[date]

convert date to string.

DateString[date, format]

use format. Named format includes the following and more, see example:

xx=DateObject[{2022,7,17,14,20,58}];

DateString[ xx , "ISODate" ] === "2022-07-17"
DateString[ xx , "ISODateTime" ] === "2022-07-17T14:20:58"

DateString[ xx , "Time" ] === "14:20:58"

DateString[ xx , "Date" ] === "Sunday 17 July 2022"
DateString[ xx , "DateShort" ] === "Sun 17 Jul 2022"
DateString[ xx , "DateTime" ] === "Sunday 17 July 2022 14:20:58"
DateString[ xx , "DateTimeShort" ] === "Sun 17 Jul 2022 14:20:58"

WolframLang: Shell Tasks