Change Date Time Format in Javascript In Any Desired Format

Last Updated on

This blog will show you how to customize date and time through javascript in different formats.

To check any condition, I have used javascript ternary operator instead of IF statement that takes three operands: a condition followed by a question mark ( ? ), then an expression to execute if the condition is true followed by a colon ( : ), and finally the expression to execute if the condition is false.

//——–To get different date format(like dd/mm/yyyy or yyyy-mm-dd and so on) from current date———-//

Just edit line number 13 in the below code and get any date format.

//——–To extract time from current date time and format as hh:mm:ss———-//

//—— To get date and time both —–//

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *