how do I get an iso formated local date that matches my OS's one in js?
@corn flour you know...
21 Replies
so
Date().toISOString()
is utc. and I'm in utc+1
I need to add an hour. how do I do so, It's fine for me to manipulate dates to get the right one for me
but I don't wanna manipulate stringsjust as confirmation so you want the format
yyyy-mm-ddThh:mm:ss
in local time right?I actually want a space instead of T. but it's a problem.
so yes. that'll work
you got pretty close, just that month needs to +1 because month start at 0
and if you are not completely attached to yyyy-mm-dd, maybe look into Intl.DateTimeFormat (theres also formateToParts which can return an array of the parts of the string instead)
I guess Intl could be my only option besides using linux posix tools I'll try Intl.
the first example on my machine is not shifted by month but 2 days forwards. which is really weird.
can you show me the code?
can I get an absolute date(without the PM/AM) with Intl
oh I can.
worked
I just have to deal with the weird m/d/y
you can yes
and the first one should be getDate, not getDay (which returns the day of the week)
im not sure about the -1 hour since i cant replicate it
unless it's behind by two months and and two days forwards???? idk, this is confusing
oh getDate worked thanks. I'll stick to the first one and add an hour
just out of curiosity, does this have 1 hour off to you?
no it's accurate. hmm interesting
and why the date is behind by month(before you add 1)?
because getMonth returns month starting at 0
for whatever reason
why are these two different in the
hour
?
maybe because 30 and 31 difference in months????i have no clue what you mean
the new Date i created works fine with my local time
maybe you're utc 0. I'm in +1.
nah im in PST