MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/btxz72/what_are_some_javascript_things_beginners_dont/ep6k13a/?context=3
r/javascript • u/[deleted] • May 28 '19
383 comments sorted by
View all comments
247
Months are zero based
0 u/[deleted] May 28 '19 [deleted] 34 u/Careerier May 28 '19 This is true, but that's something even beginners (hopefully) should know.The date thing is weird because months start at zero, but days, hours, seconds, and milliseconds start at 1.new Date(2019, 1, 1, 1, 1, 1) gives you Fri Feb 01 2019 01:01:01 1 u/PriorProfile May 28 '19 This actually makes sense in a way.Hours, minutes, seconds don’t start at 01:01:01. They start at 00:00:00.Think of it this way: your example gives you the second millisecond of the second minute of the second hour of the first day of the second month.Days are actually the odd ones. Not the months. But it would make even less sense to refer to days as 0 index I think.
0
[deleted]
34 u/Careerier May 28 '19 This is true, but that's something even beginners (hopefully) should know.The date thing is weird because months start at zero, but days, hours, seconds, and milliseconds start at 1.new Date(2019, 1, 1, 1, 1, 1) gives you Fri Feb 01 2019 01:01:01 1 u/PriorProfile May 28 '19 This actually makes sense in a way.Hours, minutes, seconds don’t start at 01:01:01. They start at 00:00:00.Think of it this way: your example gives you the second millisecond of the second minute of the second hour of the first day of the second month.Days are actually the odd ones. Not the months. But it would make even less sense to refer to days as 0 index I think.
34
This is true, but that's something even beginners (hopefully) should know.
The date thing is weird because months start at zero, but days, hours, seconds, and milliseconds start at 1.
new Date(2019, 1, 1, 1, 1, 1) gives you Fri Feb 01 2019 01:01:01
new Date(2019, 1, 1, 1, 1, 1)
1 u/PriorProfile May 28 '19 This actually makes sense in a way.Hours, minutes, seconds don’t start at 01:01:01. They start at 00:00:00.Think of it this way: your example gives you the second millisecond of the second minute of the second hour of the first day of the second month.Days are actually the odd ones. Not the months. But it would make even less sense to refer to days as 0 index I think.
1
This actually makes sense in a way.
Hours, minutes, seconds don’t start at 01:01:01. They start at 00:00:00.
Think of it this way: your example gives you the second millisecond of the second minute of the second hour of the first day of the second month.
Days are actually the odd ones. Not the months. But it would make even less sense to refer to days as 0 index I think.
247
u/TrikkyMakk May 28 '19
Months are zero based