3

How do I display a time in 24-hour format? The documentation suggests hour12="false" should do it, but this isn't working, as detailed below.

foo.js:

import { LightningElement } from "lwc";

export default class Test24HourTime extends LightningElement {
    datetime = new Date(2020, 1, 1, 20, 0, 0);
}

foo.html:

<template>
    <lightning-formatted-date-time value={datetime} hour="2-digit" minute="2-digit" hour12="false"></lightning-formatted-date-time>
</template>

Expected output:

20:00

Actual output:

08:00 pm
1
  • 4
    interestingly, if you make it a variable hour12={booleanVariable} it works. Commented Jul 2, 2021 at 14:01

0

You must log in to answer this question.

Browse other questions tagged .