2

how do I convert a LocalDateTime Object from the @js-joda/core library to a standard JavaScript Date object?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Alex Skotner
  • 462
  • 1
  • 8
  • 18
  • It's [in the documentation](https://js-joda.github.io/js-joda/manual/convert-native.html): `let date = convert(ZonedDateTime.now()).toDate();`. BTW, the documentation has inaccuracies: "*The native Date object always consist of a date, time and a timezone part.*" which is incorrect. ECMAScript dates are **only** a millisecond offset from the epoch. Dates and times are calculated from the offset, timezone information comes from the host. – RobG Feb 12 '22 at 08:35

1 Answers1

2

As @RobG mentioned in a comment import convert from '@js-joda/core' and you can use let date = convert(ZonedDateTime.now()).toDate(); to get a js date

Alex Skotner
  • 462
  • 1
  • 8
  • 18