Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Format without AM and PM #6223

Open
wb-ts opened this issue Mar 27, 2024 · 3 comments
Open

Time Format without AM and PM #6223

wb-ts opened this issue Mar 27, 2024 · 3 comments

Comments

@wb-ts
Copy link

wb-ts commented Mar 27, 2024

using moment().format('LT') , I can get result like 6:02 PM

I would like to get th result as 18:02 without setting am/pm

@antarilos
Copy link

It seems that you should use moment().format('H:mm'). (https://momentjs.com/docs/#/displaying/format/)

const date = moment();
console.log(date.format('LT')); // 9:47 PM
console.log(date.format('H:mm')); // 21:47
console.log(date.format('HH:mm')); // 21:47. Just in case you need to precede a '0' when is one digit hour: 04:21

@wb-ts
Copy link
Author

wb-ts commented Mar 29, 2024

hmm, then . @antarilos , could you please add that precede 0 there when is one digit hour? Most of time , that's used more than not including

@antarilos
Copy link

That is just what is done using date.format('HH:mm').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants