You need to sign in to do that
Don't have an account?
chikku
How can I format a date object to print as today instead of showing a numeric date in a javascript?
I'd like to display it like this: today At 5:00 PM.
This my code var today = new Date(); var date = new Date(today) date.setDate(date.getDate()-1) today.toDateString() date.toDateString() var time = today.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}); var dateTime = date+' '+time; this.dateTimeValue=dateTime;
Greetings!
Please find the sample javascript to get the current date:
Reference:https://stackoverflow.com/questions/10211145/getting-current-date-and-time-in-javascript
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri