Bordz
Bordz

Reputation: 2810

NSDate convert to 24Hours format

I want my Time to convert it to 24hrs format.

Input: 2014-07-23 07:44:47 +0000

Output: 19:44:47 <<< I want this format 24hrs

// MY Code
NSLog(@"before %@",selectedDate);
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"hh:mm a"];
NSLog(@"after %@",[dateFormat stringFromDate:selectedDate]);

this is what I got instead: enter image description here

EDIT:

Also tried: [dateFormat setDateFormat:@"HH:mm a"];

Result is:enter image description here

Upvotes: 0

Views: 90

Answers (1)

Anbu.Karthik
Anbu.Karthik

Reputation: 82759

your code is fine always understand the concept

[dateFormat setDateFormat:@"hh:mm a"];

hh- 12 hour format

HH - 24 hour format 


  [dateFormat setDateFormat:@"HH:mm a"];

remind that always, K

Upvotes: 1

Related Questions