hot to get the time in JS code example

Example 1: javascript get current time

var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

Example 2: how to use current data in javascript

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();

Example 3: currentTime(); javascript

var d = new Date("2020-12-09T05:30:51.01");
d.getHours(); // => 05
d.getMinutes(); // =>  30
d.getSeconds(); // => 51

/*2020 stand for year
12 stands for moth
and 09 stands for the date.
the T there seperates the date and time
!!!IMPORTANT THE VALUE IS A STRING!!!*/

Tags:

Php Example