Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    JSJavaScript

    Getting started

    • What is JavaScript?
    • Variables: let, const and var
    • Data types
    • Type conversion

    Operators and strings

    • Arithmetic and assignment
    • Comparison and logic
    • Strings and template literals
    • String methods
    • Numbers and Math

    Control flow

    • Conditions: if and else
    • switch and the ternary operator
    • Loops: for and while
    • Challenge: FizzBuzz

    Functions

    • Functions
    • Arrow functions
    • Parameters: default, rest and spread
    • Scope and closures
    • Callbacks and higher-order functions

    Arrays

    • Array basics
    • map, filter and find
    • reduce and sorting
    • Destructuring

    Objects

    • Object basics
    • Copies and references
    • Methods and this
    • JSON and optional chaining

    Classes and OOP

    • Classes
    • Inheritance

    JavaScript in the page

    • Controlling the page (DOM)
    • Creating elements
    • Events
    • Forms and validation
    • Saving in the browser (localStorage)

    Errors and async

    • Handling errors: try and catch
    • Timers and the event loop
    • Promises
    • async and await
    • Fetching data from an API

    Practical tools and techniques

    • Searching with regular expressions
    • Cancellation and stale results
    • Testing and debugging JavaScript

    Modern JavaScript and a project

    • Map and Set
    • Dates and localised formatting
    • Modules: import and export
    • Project: a complete to-do app
    JavaScript

    Modern JavaScript and a project · Lesson 43 of 45

    Dates and localised formatting

    Date, and showing dates, numbers and money in Arabic and English.

    7 minutes2 games

    new Date() gives the current time; new Date(2026, 0, 15) builds a date (months start at 0: January is 0!). To display dates nicely in any language, use Intl.

    JavaScript
    const exam = new Date(2026, 11, 20, 10, 30)
    console.log(exam.getFullYear(), exam.getMonth() + 1, exam.getDate())
    
    const opts = { weekday: "long", day: "numeric", month: "long", year: "numeric" }
    console.log(new Intl.DateTimeFormat("en-US", opts).format(exam))
    console.log(new Intl.DateTimeFormat("ar-EG", opts).format(exam))
    
    const days = Math.ceil((exam - new Date(2026, 10, 30)) / (1000 * 60 * 60 * 24))
    console.log(days, "days to go")
    
    console.log(new Intl.NumberFormat("ar-EG", { style: "currency", currency: "EGP" }).format(1499.5))
    console.log(new Intl.NumberFormat("en-US").format(1234567.891))

    Important

    Subtracting two dates gives the difference in milliseconds. Divide by 1000 * 60 * 60 * 24 for days.

    Interview question

    How do you store and send dates between server and browser without time-zone trouble?

    What's the output?

    const d = new Date(2026, 0, 31)
    console.log(d.getMonth())

    What will this code print?

    Exercise

    Print the number of days between 1 and 31 March 2026 in UTC (30) so daylight-saving changes do not alter the result.

    Expected output: 30

    JavaScript
    const start = new Date(Date.UTC(2026, 2, 1))
    const end = new Date(Date.UTC(2026, 2, 31))
    

    Learn more from

    • javascript.info: Date and timejavascript.info
    • MDN: Intl.DateTimeFormatdeveloper.mozilla.org
    • MDN: Intl.NumberFormatdeveloper.mozilla.org

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousMap and SetNextModules: import and export
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.