Language type of JavaScript
Precedence And Associativity of Operators
HTTP Status Code
Posted on
Introduce Concept of BOM - Browser Object Model
JS Dungeon Level3: Calculator
Posted on
In
JS Dungeon
Differences between Screen, Client, and Page
JS Dungeon: To-Do-List
How to handle Time issue in JavaScript
Posted on
Edited on
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();
- Get year: