Skip to content

Commit

Permalink
date and time
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshchoudhary committed Mar 1, 2023
1 parent 4987ece commit d775065
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 01_basics/07_datesinJs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Dates

let myDate = new Date()
// console.log(myDate.toString());
// console.log(myDate.toDateString());
// console.log(myDate.toLocaleString());
// console.log(typeof myDate);

// let myCreatedDate = new Date(2023, 0, 23)
// let myCreatedDate = new Date(2023, 0, 23, 5, 3)
// let myCreatedDate = new Date("2023-01-14")
let myCreatedDate = new Date("01-14-2023")
// console.log(myCreatedDate.toLocaleString());

let myTimeStamp = Date.now()

// console.log(myTimeStamp);
// console.log(myCreatedDate.getTime());
// console.log(Math.floor(Date.now()/1000));

let newDate = new Date()
console.log(newDate);
console.log(newDate.getMonth() + 1);
console.log(newDate.getDay());

// `${newDate.getDay()} and the time `

newDate.toLocaleString('default', {
weekday: "long",

})

0 comments on commit d775065

Please sign in to comment.