24 hour date format does not work
See original GitHub issueProblem
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:
Verified on plain angular just in case and it does work:
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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'}}
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/PMI 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)