Hi all,
where could i find a good documentations about “moment” or “date” ??!
It’s really complex to understand how works this class…
Today is month October( month n° 10) and when i write
“moment().month()” return 9.
“moment().months()” return 9;
“moment().utc).month()” return 9;
“moment().local().month()” return 9;
but if i write in console “moment” it has the value 10 .
anyone know?!
new Date().getMonth() // 9 (index-0)
moment().format(‘M’) // 10 (month as digit)
if you are in a position to choose the library, i would recommend against a mutable API like moment.
1 Like
Thank you to help me.
Meanwhile i tryed to study moment etc and i create this “date-helper”… and seems working…
Do you suggest anyway to use luxon ?
I think that moment functions can be comprehensive… or no?
timfish
October 17, 2018, 12:23pm
5
Luxon is much smaller and simpler because it relies on newer browser API’s for i18n and timezones. Check out the support matrix .
If you need to support i18n and timezones in older browsers you’ll need to use moment + plugins and the whole lot can be quite large.
1 Like
After hours spent on “try” to understand how to work with moment / date of typescript i try this Luxon. It seems workable but how can i get a Luxon DateTime from European Timezone date?
With LUXON i’m not able to return to localtime from UTC.
anyone know?
Try e.g. DateTime.local().setZone(‘Europe/Paris’);
UTCDate.toLocal().plus({ minutes: UTCDate.offset }).toFormat(“dd/MM/yyyy HH:mm”));
this is the answer! but it can be possible to write this entire line to have the local time from utc…
if you have a utc date you can just add Z to the end and it will convert local for you
let localTime = new Date(utcDate + “Z”);