Published Nov 14, 2023
Contribute to Docs

The kotlinx.datetime library is designed to help Kotlin programmers with the most common issues dealing with date and time values. It emphasizes convenience so the API is as minimal as possible. The GitHub repository for the library has instructions on how to include a dependency in a Kotlin project.

The library uses the ISO 8601 standard and does not provide other ways to represent dates and times. It also doesn’t provide internationalization, so it can’t provide locale specific month and day names.

Below are various elements of the kotlinx.datetime library:


Finds an instant that corresponds to the start of a date in a particular time zone.
Returns a DateTimePeriod object to indicate the time difference between two dates.
Returns the number of days between two Instants.
Returns the difference between two dates or a date and a unit of time.
Finds the offset from UTC this time zone has at the specified instant of physical time.
Provides the time zone offset at a specific point in time.
Returns an object representing the difference between two dates.
Parses the ISO-8601 duration representation as a DatePeriod.
Interprets an ISO-8601 formatted duration string, converting it into a DateTimePeriod object.
Returns a date for the given Clock value and time zone passed.
Converts a string representing an instant in ISO-8601 format, which includes both date and time components along with the time zone offset, into an Instant value.
Returns the name of the weekday based on the integer given, Monday is set as 1.
Returns an instance of a month object based on the integer given.

All contributors

Looking to contribute?

Learn Kotlin on Codecademy