I want to convert this:
04/01/2021 02:06:22 PM
to:
04/01/2021 14:06:22
I tried many things but not success, thank you for your help
CodePudding user response:
Use the toLocaleString()
method to change time formatting to 24 hours, e.g. date.toLocaleString('en-US', {hour12: false})
. The toLocaleString
method returns a string that represents the date and time according to the provided locale and options parameters.
const date = new Date();
console.log(
date.toLocaleString('en-US', {
hour12: false,
}),
);
CodePudding user response:
try this:
date.toLocaleString("fr");