Date

4 minutes
Share the link to this page
Copied
  Completed

Transcript

Hello, in this JavaScript video, I am going to show you the data objects. And this is really cool. You can get, you know, like the day them in a milliseconds, you can, you know, do a bunch of manipulation. As usual, there's so much, you know, so many features to be at showcase just in one quick video. But if you understand what we're going to cover in a moment, then you'd be good to go. I'll provide a link to the Mozilla Developer Network, amazing website, and you'll see all the different, you know, properties and the methods that you can utilize.

Okay, so to create a object like a few different ways, I'll show you the most basic way. So this is called OBJ equals date. They have the date object has a optional parameter last of a millisecond date string. We can just keep it simple like this. Like I said, I'll provide a link where you can extend it as long as you understand what we're doing here. Good to know.

So now, let's just do console dot log, and see what the actual date object as of now before we utilize any of its properties actually have what it is. So it's a Saturday November 3, which is you know, is the date. And it's a free 1007. And so I'm guessing if I was to be loaded, the seconds are changing. Greenwich Mean Time. Yes, I am in the UK.

So all of that lines up, that's pretty darn cool. But again, we might not just want it like simpler this we might want a bit more, lift over to the console dot log. Another date object, we could get more Should we get this get the year. Maybe we just need the year. Maybe this is to do with some with at least want to check the age of what you put in. There do not work.

So what have I done wrong? Clearly I've done something wrong. So date OBJ that's also currently dot get full year. I don't see anything. Specifically law Yeah. Are you being serious?

I think I know what the issue is. I can't believe I made this mistake. But the but the new keyword is an object, keyword. There we go. Well, I wasn't able to access this before. range of properties, okay, so 2018, that is pretty darn cool, you can get a bunch of other stuff as well.

So you can get, you know, the UT c equivalent of the hours, the millisecond, the minutes, the monster seconds. So you can, you know, you can set the year manually. So if you want to override that, you can get the strings equivalent of these as well. So, to get the string equivalent, let's say, console dot log, date, obj.to. string, save that refresh, we get so that is the string equivalent, and not just like a simple object. Also, what we get is to find string, and I think you can guess what this does.

This just gets the time portion of the string and there are methods to be able to just purely get it hours and you can set the hours and minutes, even go go down as far as milliseconds or something specific days. That's it. As long as you understand how to create it, make sure you put the new keyword I, you know, forgot at the start. This is how you use it and you're good to go. I'll provide a link with all of the properties listed on there. As usual, thank you for watching, and if you have any other videos on any of the videos on the one provided videos, if you have any questions, feel free to call me message and I look forward to seeing you in the next video, which I'll be provided.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.