Wednesday, September 20, 2023

Type Script part 5 Date type

Date is a non primitive value stored in memory heap by using date constructor

The data type in typescript to store date value is defined with  "any" type

The memory for date value is allocated by using dynamic memory allocation operator "new" and date constructor.


Type script uses following date functions

getHours()--> returns the hour number in 24 hour format

getMinutes()--> return the minute number.

getSecond()-->return the second number.

getDay()--> return the week day number.

Example Sunday=0

getDate()---Returns the date number

getMonth()-->Returns the month number

getYear()-->Returns the year number as per y2k

getFullYear()--> Returns full year number

toLocaleDateString()-->Returns short date format

toLocaleTimeString()-->Returns short time format

Example


let mfd:any=new Date();
console.log(mfd.getDate())
console.log(mfd.getMonth())
console.log(mfd.getYear())
console.log(mfd.getFullYear())
console.log(mfd.getHours())
console.log(mfd.getMinutes())
console.log(mfd.getSeconds())
console.log(mfd.getDay())

Output

















No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...