Welcome back to Learn to Code and JavaScript in this lecture.
We're going to start talking about dates.
First thing I want to say about dates before we get into too far is that most people don't use the JavaScript
dates.
For the most part.
They'll generally use a library such as Moment Jass, which provides a lot more solid date and time
manipulation.
But we'll take a look here and we will explain what the JavaScript dates are.
So JavaScript data is stored as a number and it's milliseconds since January 1st, 1970 in UTC, which
is the universal time coordinated or Greenwich Mean Time.
So it's a number of milliseconds and before that, time is a negative number.
So, again, most people use the moment, such as library.
So what are the reasons for this?
So in my experience, you can end up with dates that are numbers or objects or strings and with moments.
Yes, it's just nice to have them be a moment object.
So there's two common ways to create a date.
One is to use the new date, which is a constructor, which will talk about more later.
But the new date, you can just specify a string or other formats such as year, month, day, are minutes,
seconds, milliseconds.
You don't have to specify all those.
You just say 20, 21, five, 12.
And that creates a new date.
Both those create a new date.
Now, there's one issue.
There's another issue why people don't like the JavaScript date, which is that the five is not May.
It's June because the JavaScript months start with zero, so January is zero, so it's another thing
called data.
Now, it doesn't really create a date.
It just returns the number of milliseconds since January 1st, 1970.
And so all these are little reasons why people don't like the JavaScript date very much.
So once you have a date, their instance methods, kind of like with strings.
So here are some selected methods.
So when you have a date such as my date, you say get a date, which gets the day of the month, one
three 31.
You say get full year, which gets the four digit year.
And there's a bunch of other guests, as you can see here, get ours, 033, get milliseconds, zero
nine nine nine minutes, get month, you get month is zero to 11, which is kind of confusing.
Get second zero to fifty nine UTC hours.
So get the hours and the UTC time zone.
Let's say it's five o'clock in the Eastern Time zone, it might be ten o'clock at UTC.
And then there's a bunch of set methods as well.
Set month, set minute and so on.
So let's look at some date examples in TVs code.