Alexandru Gheorghe
06/05/2024, 5:51 AMAwkin
06/05/2024, 7:06 AMAlexandru Gheorghe
06/05/2024, 7:10 AMdate1 = "2024-05-17 22:05"
date2 = "2024-05-18 12:44"
I want the delta in milliseconds between date2
and date1
AND also for the cases where date2
is before date1
(e.g. date2 = "2024-05-17 22:04"
)Awkin
06/05/2024, 7:12 AMAlexandru Gheorghe
06/05/2024, 7:16 AMAwkin
06/05/2024, 7:18 AMInstant
, then, subtract them: https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-instant/minus.html (the second overload in the list)Sam
06/05/2024, 8:50 AMShould I convert to UTC?Converting to UTC will give you an answer, but it's not the only answer. DST means the duration between two otherwise identical
LocalDateTime
instances can be different depending on your location. If your dates and times correspond to real events in the real world, you need to use the actual timezone in which those events take place.Alexandru Gheorghe
06/05/2024, 9:18 AMSam
06/05/2024, 9:41 AMSam
06/05/2024, 9:42 AMAlexandru Gheorghe
06/05/2024, 9:43 AMSam
06/05/2024, 9:46 AMAlexandru Gheorghe
06/05/2024, 9:47 AMSam
06/05/2024, 9:49 AM