Fly with code

Get wet inside ocean of code

0%

Basic Syntax

  • Declare a variable to store date data.

    1
    let time=new Date(); // get the current time data
    • Get year: let year = time.getFullYear();
    • Get month: let month=time.getMonth()+1;
      • Be aware that for month data, it will count from 0.
    • Get weekday: let weekday=time.getDay();
      • Be aware that for weekday data, it will count from 0.
    • Get hour: let hour=time.getHours();
    • Get minute: let minute=time.getMinutes();
    • Get second: let second=getSeconds();
    • Get milliseconds: let time.getMilliseconds();
    • Get time stamp: let stamp=time.getTime();
      Read more »