.todayIn()
Anonymous contributor
Published Nov 29, 2023
Contribute to Docs
The .todayIn()
method returns a date when called on a Clock
while passing a TimeZone
argument.
Syntax
myClock.todayIn(myTimeZone)
myClock
: A Clock providing a source for Instants (e.g., 2023-11-21, 00:00:00 UTC+0).Clock.System
is the clock that refers to the current platform for the current time.myTimeZone
: An instance of theTimeZone
class (e.g., America/Los_Angeles).
Example
The example below demonstrates a basic implementation of .todayIn
that returns the current date.
// Import all classes from kotlinx.datetime package.import kotlinx.datetime.*fun main() {val myLocalDate = Clock.System.todayIn(timeZone = TimeZone.currentSystemDefault())println(myLocalDate)}
This example results in an output similar to the following:
2023-11-21
All contributors
- Anonymous contributor
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.