---
title: DateTime API
slug: v111/datetime-api
icon: {"faIcon":"fa-solid fa-clock"}
docTags: 
createdAt: 2025-06-10T06:44:31.749Z
---

| Constructor                                | Description                                          |
| ------------------------------------------ | ---------------------------------------------------- |
| DateTime()                                 | Current date, with default locale and Time Zone      |
| DateTime(\<DateTime>)                      | Clone from an existing DateTime object               |
| DateTime(\<string\_date>)                  | Attempt to parse the date using the default format   |
| DateTime(\<string\_date>, \<date\_format>) | Attempt to parse the date using the specified format |

| Method                                                          | Description                                                                                                                                                                           |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| withYear(year: Int): DateTime                                   | Sets the DateTime Object with the year that was passed in as the parameter.                                                                                                           |
| withMonthOfYear(month: Int): DateTime                           | Sets the DateTime Object with the month that was passed in as a parameter                                                                                                             |
| withDayOfMonth(day: Int): DateTime                              | Sets the DateTime Object with the day that was passed in as a parameter.                                                                                                              |
| withHourOfDay(hour: Int): DateTime                              | Sets the DateTime Object with the hour that was passed in as a parameter.                                                                                                             |
| withMinuteOfHour(minute: Int): DateTime                         | Sets the DateTime Object with the minute that was passed in as a parameter.                                                                                                           |
| withSecondOfMinute(second: Int): DateTime                       | Sets the DateTime Object with the second that was passed in as a parameter.                                                                                                           |
| withMillisOfSecond(millis: Int): DateTime                       | Sets the DateTime Object with the milliseconds that was passed in as a parameter.                                                                                                     |
| plusYears(years: Int): DateTime                                 | Adds the number of years passed in as a parameter to the current DateTime.                                                                                                            |
| plusMonths(months: Int): DateTime                               | Adds the number of months passed in as a parameter to the current DateTime.                                                                                                           |
| plusDays(days: Int): DateTime                                   | Adds the number of days passed in as a parameter to the current DateTime.                                                                                                             |
| plusHours(hours: Int): DateTime                                 | Adds the number of hours passed in as a parameter to the current DateTime.                                                                                                            |
| plusMinutes(minutes: Int): DateTime                             | Adds the number of minutes passed in as a parameter to the current DateTime.                                                                                                          |
| plusSeconds(seconds: Int): DateTime                             | Adds the number of seconds passed in as a parameter to the current DateTime.                                                                                                          |
| plusMillis(millis: Int): DateTime                               | Adds the number of milliseconds passed in as a parameter to the current DateTime.                                                                                                     |
| minusYears(years: Int): DateTime                                | Subtracts the number of years passed in as a parameter to the current DateTime.                                                                                                       |
| minusMonths(months: Int): DateTime                              | Subtracts the number of months passed in as a parameter to the current DateTime.                                                                                                      |
| minusDays(days: Int): DateTime                                  | Subtracts the number of days passed in as a parameter to the current DateTime.                                                                                                        |
| minusHours(hours: Int): DateTime                                | Subtracts the number of hours passed in as a parameter to the current DateTime.                                                                                                       |
| minusMinutes(minutes: Int): DateTime                            | Subtracts the number of minutes passed in as a parameter to the current DateTime.                                                                                                     |
| minusSeconds(seconds: Int): DateTime                            | Subtracts the number of seconds passed in as a parameter to the current DateTime.                                                                                                     |
| minusMillis(millis: Int): DateTime                              | Subtracts the number of milliseconds passed in as a parameter to the current DateTime.                                                                                                |
| getYear(): Int                                                  | Gets the year of the current DateTime object.                                                                                                                                         |
| getMonthOfYear(): Int                                           | Gets the month of the current DateTime object.                                                                                                                                        |
| getDayOfMonth(): Int                                            | Gets the day of the current DateTime object.                                                                                                                                          |
| getHourOfDay(): Int                                             | Gets the hour of the current DateTime object.                                                                                                                                         |
| getMinuteOfHour(): Int                                          | Gets the minute of the current DateTime object.                                                                                                                                       |
| getSecondOfMinute(): Int                                        | Gets the second of the current DateTime object.                                                                                                                                       |
| getMillisOfSecond(): Int                                        | Gets the millisecond of the current DateTime object.                                                                                                                                  |
| isAfter(dateTime: DateTime): Boolean                            | Determines if the DateTime object is after the DateTime Object passed in.                                                                                                             |
| isBefore(dateTime: DateTime): Boolean                           | Determines if the DateTime object is before the DateTime Object passed in.                                                                                                            |
| isEqual(dateTime: DateTime): Boolean                            | Determines if the DateTime object is the same the DateTime Object passed in.                                                                                                          |
| isAfterOrEqualTo(dateTime: DateTime): Boolean                   | Determines if the DateTime object is after or equal to the DateTime Object passed in.                                                                                                 |
| isBeforeOrEqualTo(dateTime: DateTime): Boolean                  | Determines if the DateTime object is before or equal to the DateTime Object passed in.                                                                                                |
| withTimeAtStartOfDay(): DateTime                                | Sets the DateTime object to the time of the start of the day.                                                                                                                         |
| isSameDay(dateTime: DateTime): Boolean                          | Determines if the DateTime object is the same day as the DateTime object passed in                                                                                                    |
| withDate(year: Int, month: Int, day: Int): DateTime             | Sets the DateTime object passed on the parameters                                                                                                                                     |
| withTime(hour: Number, second: Number, milli: Number): DateTime | Sets the DateTime object wit the time passed in as a parameter.                                                                                                                       |
| toISOFormat(): String                                           | Gets the isoformat of the current dateTime object                                                                                                                                     |
| toISOFormatGMT(): String                                        | Gets the isoformat of the current datetime object in GmT                                                                                                                              |
| toLocalDateTime(zone: String): DateTime                         | Converts a DateTime (with an associated TimeZone) to the same local DateTime on another TimeZone.<br />- E.G.  01/Jan/2020 10:00 GMT will become 01/Jan/2020 10:00 in the target zone |
| fromNow(): String                                               | Checks what the DateTime object is in comparison of now.                                                                                                                              |
| withZone(\_zone: String): DateTime                              | Adds a TimeZone to the DateTime object                                                                                                                                                |
| withLang(\_locale: String): DateTime                            | Adds a locale to the DateTime object                                                                                                                                                  |
| format(format: String): String                                  | Sets the format of the DateTime object based on Joda DateTime.                                                                                                                        |

