Loading video player…

Reading Date Strings With Date

A full timestamp and a calendar date carry different meanings. Dana’s appointment has a UTC marker, Z, so it names one moment on either laptop. In Python, read it as an aware datetime; in JavaScript, pass the full timestamp to Date.

The JavaScript timestamp example from the video is:

Language: JavaScript
const text = "2026-11-01T15:00:00Z";
const start = new Date(text);
console.log(start.toISOString());

It prints the same moment in either machine zone:

Language: Program Output
2026-11-01T15:00:00.000Z

A bare string such as "2026-11-03" becomes midnight UTC when read by Date. In New York, that moment is Monday evening, so .toDateString() gives Mon Nov 02 2026. The clinic’s Date check rebooks Jonas instead of Fiona. Python’s date keeps the closure as a calendar day, and its explicit London conversion keeps the clinic’s rule independent of the laptop.

Date has no date-only type. Keep calendar-day rules separate from moments; a later section uses Temporal.PlainDate for that job. For an unreadable parse, check Number.isNaN(parsed.getTime()): Invalid Date has a NaN time value. Subtracting Dates gives milliseconds, not a Python timedelta with a .days attribute.

Next up: Exercise: Check the Holiday Closures. Check the office manager’s closure entries for the clinic.

00:00 In this lesson, you’ll read the clinic’s export with Date and check which appointments fall on its closed day. Dana’s Sunday appointment has a timestamp ending in Z, meaning Coordinated Universal Time, or UTC.

00:13 In Python, reading that text gives an aware datetime. In JavaScript, the same text goes into the Date constructor.

00:26 The ISO string shows the same moment, with zero milliseconds added to the display. ISO 8601 is the standard date-and-time format used here. But the training day has only a calendar date.

00:42 The clinic closes on Tuesday, the third of November, for staff training. In Python, the closure stays a date, with no time attached. Each appointment is read as a datetime, shown in the clinic’s London zone, and reduced to its date.

00:56 The check rebooks Fiona. In the JavaScript port, Date reads the closure string too.

01:08 The new date-string method returns a readable date in the machine’s local zone. The loop checks each appointment; triple equals compares the two strings.

01:17 On Isla’s Edinburgh laptop, the port also rebooks Fiona. Callum runs the same check on his laptop in New York. For this demonstration, the first line sets the runtime’s local time zone; it works on Windows, macOS, and Linux.

01:36 Only that setting changes. The export and the comparison stay the same. Which patient gets the rebooking line? Your turn: pause the video and predict the patient.

01:52 Jonas gets the line. Fiona gets no line, although the clinic is still closed on Tuesday. The closure string has no time, but Date gives it midnight UTC.

02:07 The ISO display stays the same on both laptops. In New York, that moment is Monday evening, at seven. The local date-string method therefore says Monday, November second.

02:21 The local day getter gives two; the UTC day getter gives three. Jonas’s Monday appointment is Monday there too, so its string matches. Fiona’s Tuesday appointment is Tuesday there, so it doesn’t match.

02:37 The machine changed the meaning of the closure check. The Python split tells you what the port needs: a moment for an appointment, and a calendar day for the closure.

02:48 Date can hold the moment, but it has no date-only value.

02:55 Adding a time or choosing another getter doesn’t restore that missing distinction. Keep the appointment’s full timestamp, including its Z or offset. Keep the closure’s calendar meaning separate.

03:08 A later section uses Temporal.PlainDate for that job. For this Date port, you’ve found a boundary rather than a clean calendar-day fix.

03:18 Watch out: a string such as 31/10/2026 gives an Invalid Date with a NaN time instead of Python’s ValueError, so use Number.isNaN() on its millisecond value and prefer the ISO format.

03:39 Watch out: Dana’s Sunday Date minus the Thursday run’s Date gives a millisecond number, not Python’s timedelta, so its days property is undefined.

03:51 Read the meaning of each export field before choosing its type. A full timestamp with a zone marker identifies one moment on both laptops. A bare date doesn’t become a portable clinic day by going through Date.

04:04 Keep that calendar rule separate, and check parsed values before using them. Next up: Check the Holiday Closures. You’ll check the office manager’s closure entries for the clinic.

Become a Member to join the conversation.