question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

24 hour date format does not work

See original GitHub issue

Problem

The date pipe does not respect the 24 hour format (it always shows 12 hours format)

Context

Verified on iOS emulator / 9.1

  • tns-core-modules: 2.3.0
  • tns-ios: 2.3.0

How to reproduce it

  • Create a sample application (tns create Sample --ng) and for example introduce the same: app.component.ts:
import {Component} from "@angular/core";

@Component({
    selector: "my-app",
    templateUrl: "app.component.html",
})
export class AppComponent {
    public myDate = new Date("Tue Nov 15 2016 21:02:49 GMT-0300 (UYT)");
    ...
}

app.component.html

<StackLayout>
    ...
    <Label [text]="myDate | date:'d/MMM/yy H:m'"></Label>
    <Label [text]="myDate | date:'d/MMM/yy j:m'"></Label>
</StackLayout>

You should see H:m uses 12 hours format instead of 24, check out the screenshot: simulator screen shot nov 15 2016 08 13 52

Verified on plain angular just in case and it does work: screen shot 2016-11-15 at 08 16 13

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
sanidzcommented, Sep 13, 2018

Solution is really simple, just use ‘HH’ for 24hour format and ‘hh’ for 12. {{"field | date: 'HH.mm'" }}

@shaikhspear16 For custom formats just use multiple interpolations like… {{myDate | date: 'dd'}}/{{myDate | date: 'MM'}}

3reactions
ignaciolarranagacommented, Nov 15, 2016

Hi @NickIliev, I might not explain it clearly, if you place this: <Label [text]="myDate | date:'d/MMM/yy H:m'"></Label> It doesn’t show a 24 hour format, but instead the hour in 12 hour format but without the AM/PM

I also include in the same example the other format: <Label [text]="myDate | date:'d/MMM/yy j:m'"></Label> to show that the variable actually has the right value (21:02)

Read more comments on GitHub >

github_iconTop Results From Across the Web

converting date time to 24 hour format - java - Stack Overflow
I want to convert it to yyyy-MM-dd HH:mm:ss . I also want the converted time to be in 24 hour format. Can any...
Read more >
I don't seem to have 24 hour clock format on my windows 10 ...
I bought a new computer and installed Windows 10 on it and I want to change the clock format to 24 hours, but...
Read more >
Set 12 vs 24 hour with the new date formatting API in iOS 15
The problem that I'm having is figuring out how to force the new API to display 12 vs 24h times. So, for example,...
Read more >
Support different 12/24 hour clock, date formats and start of ...
Hi, I know this is created in the USA, but for those of us not living there, we have different setups for time/date...
Read more >
New Date.FormatStyle: Anyway to do 24 hour? - Swift Forums
The problem is the new Text<F>(F.FormatInput, format: F) only use Locale from environment, but not for TimeZone and Calendar . I think it's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found