.datetime()
Published Jun 7, 2022
Contribute to Docs
The .datetime()
method returns a new object with date and time properties.
Syntax
datetime.datetime(YYYY, MM, DD, hh, mm, ss)
The following parameters must be valid when passed into the .datetime()
method:
Parameter | Required? | Description | Range |
---|---|---|---|
YYYY |
✓ | The year expressed in one to four digits. | 1 - 9999 |
MM |
✓ | The month expressed in one or two digits. | 1 - 12 |
DD |
✓ | The day of the month expressed in one or two digits. | 1 - the number of days in a given month and year |
hh |
✕ | The hour in a given 1-day period that can be expressed as one or two digits. | 0 - 24 |
mm |
✕ | The minute in a given 1-hour period that can be expressed as one or two digits. | 0 - 60 |
ss |
✕ | The second in a given 1-hour period that can be expressed as one or two digits. | 0 - 60 |
Codebyte Example
A date and time can be retrieved and stored in a variable as shown below:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.