‫Okay.
‫So now we're going to look at functions to help us with dates and times.
‫And in particular we're going to be looking at the date function.
‫And there's a lot you can do with that.
‫There's a lot of different arguments that you can pass in if you want, just the year or you want the
‫full date or you want just the hour.
‫I mean, you can get any, any part of the date or time that you want and any date a time that you want,
‫whether it's today or whether it's 100 years ago.
‫So I'm just going to paste in a comment just so I can kind of show you the main options or main arguments.
‫So I'll put this in.
‫Let's put this in a.
‫Multi-line comment so we can pass in these to get like uppercase W, y will get the year.
‫Lowercase m will get the month.
‫Lowercase d is the day, uppercase D is the day of the week.
‫Short name.
‫You can get the full day of the week name with L.
‫So tons of different options.
‫So let's start off by taking our output variable.
‫And let's set it to just date with nothing and reload.
‫Um.
‫Oh.
‫I'm sorry.
‫We have to pass at least one parameter in here.
‫So let's start off with just the uppercase Y.
‫Reload that and we get 2023.
‫So that just gives us the year.
‫All right.
‫Now we can also work with timestamps.
‫A timestamp is a number that represents a specific date and time.
‫It's commonly represented as the number of milliseconds that have elapsed or passed since a specific
‫reference point in time, called the epoch.
‫And the epoch is January 1st, 1970, so it's the number of milliseconds that have passed since then.
‫Now we can do a few things here.
‫We can get the date from a timestamp from if we know that timestamp.
‫So that's what I'm going to do.
‫First is let's say output set that to date.
‫And I want the year right.
‫And then I'm going to pass in a specific timestamp of 936345 600.
‫So that's a specific timestamp.
‫And if I reload you see that that's a timestamp for 1999.
‫Now obviously you're not going to remember the timestamp for a specific date, but you can use string
‫to time or str to time to get the timestamp for a specific date.
‫So for instance, if we say output equals and let's say date.
‫And let's say we want to get the year.
‫But then I want to pass in here STR to time.
‫And then I'm going to put a date in here formatted as 1990 909.
‫And zero one.
‫So reload and we still get 1999.
‫So this right here is giving me the same as this or whatever the timestamp is for this exact date.
‫Now let's continue to look at different options that we can pass into the date function.
‫So.
‫Uh, let me just put some comments in here.
‫We'll say get your.
‫Get year with.
‫Timestamp and we'll say get.
‫Timestamp from str to time.
‫Okay, so let's say we want to get the month.
‫So we'll set output equal to date.
‫And we're going to pass in here a lowercase m.
‫If I do that.
‫I'm going to get 11 now.
‫This will give me the the current month since I'm not passing in a timestamp.
‫Right.
‫Or I'm not passing in a specific date.
‫So it's talking about now and it's November.
‫It's November 1st, so it's giving me 11 now if you want to get the day.
‫Let's say oops let's say get day.
‫We'll say output equals date.
‫And we want to pass in here.
‫Let's do an uppercase D.
‫So if I do that it's going to give me the the abbreviation.
‫If you want the full day name then you can use L.
‫So that gives me Wednesday.
‫Now, if I wanted to get the year, month and day, I could pass in all three.
‫So I'll say output, set that to date and let's pass in uppercase Y dash m dash d.
‫Reload that and let's see, I forgot.
‫I forgot quotes.
‫Get rid of these spaces.
‫So I get the date 2023 1101 and you can.
‫If you don't like that format, we can change it.
‫We can do month, day, day.
‫Why?
‫Or month, day, year.
‫That gives me 1101 2023, which is more of the the way the US formats dates.
‫So let's say get month, day and year.
‫Now let's look at time.
‫So let's say we want to get get the hour.
‫So to do that we can set output equals to date.
‫And we want to pass in here lowercase h.
‫Okay.
‫So if we run that I get oh seven.
‫If we want to get the minute.
‫We'll set output equal to date.
‫Now the minute is I lowercase I.
‫So if I do that, we get 41.
‫And then if you want to get the second, that's going to be.
‫Lowercase s.
‫So date.
‫Lowercase s.
‫Reload.
‫That's a second.
‫And if I reload again, you'll see it's going to keep changing because obviously it changes every second.
‫So if you want to put all that together actually before we do that we can also get a m or p m.
‫So let's say output equals date.
‫And what we want to pass in for that is a lowercase a.
‫So we get PM.
‫Now let's say put it all together.
‫So we'll say output equals date.
‫And I want to.
‫I want the date and the time.
‫So let's do uppercase Y.
‫So year dash month day.
‫Then we're going to put a colon and then I.
‫And then we're going to put another colon s and then a space and a.
‫So this is a common format.
‫If I reload we get 2223 1101.
‫And we get.
‫Wait a minute.
‫What am I missing here?
‫I'm missing the hour.
‫So after the D space.
‫And then we want the hour.
‫There we go.
‫So.
‫740 2:51 p.m. if I reload, that second is going to change, obviously, and you can format the date
‫and time however you want.
‫If you want to see all the options that you can pass in and all the different things you can do, you
‫can also visit this link in the documentation.