Go to: Synopsis. Return value. Keywords. Flags. Python examples.

Synopsis

date([date=boolean], [format=string], [shortDate=boolean], [shortTime=boolean], [time=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

date is NOT undoable, NOT queryable, and NOT editable.

Returns information about current time and date. Use the predefined formats, or the -format flag to specify the output format.

Return value

string

Keywords

time, date

Flags

date, format, shortDate, shortTime, time
Long name (short name) Argument types Properties
date(d) boolean create
Returns the current date. Format is YYYY/MM/DD
format(f) string create
Specifies a string defining how the date and time should be represented. All occurences of the keywords below will be replaced with the corresponding values: YYYYYYMMDDhhmmss
KeywordBecomes
Current year, using 4 digits
Last two digits of the current year
Current month, with leading 0 if necessary
Current day, with leading 0 if necessary
Current hour, with leading 0 if necessary
Current minute, with leading 0 if necessary
Current second, with leading 0 if necessary
shortDate(sd) boolean create
Returns the current date. Format is MM/DD
shortTime(st) boolean create
Returns the current time. Format is hh:mm
time(t) boolean create
Returns the current time. Format is hh:mm:ss

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Get the current date and time
cmds.date()
# Result:2006/03/09 16:50:24 #
# Get only the month and day
cmds.date( shortDate=True )
# Result:03/09 #
# Get the date and time in a fancy format
cmds.date( format='Year is YY (or YYYY), month is MM, day is DD. And it is now hh:mm:ss' )
# Result:Year is 06 (or 2006), month is 03, day is 09. And it is now 16:53:20 #