---
title: "NSDateFormatter, am I doing something wrong or is this a bug"  
description: "NSDateFormatter, am I doing something wrong or is this a bug"  
author: "Tarun Kumar"  
published: 2015-08-03  
updated: 2015-08-03  
canonical: https://www.mindstick.com/forum/33390/nsdateformatter-am-i-doing-something-wrong-or-is-this-a-bug  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# NSDateFormatter, am I doing something wrong or is this a bug

I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to [print](https://www.mindstick.com/blog/301752/types-of-3d-printing-technology) out the date in a certain [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format):

```
NSDate *today = [[NSDate alloc] init];NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];[dateFormatter setDateFormat:@"yyyyMMddHHmmss"];NSString *dateStr = [dateFormatter stringFromDate:today];
```

If the iPhone is set to 24 hour time, this [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why), if on the other hand the user has set it to 24 hour time, then back to AM/PM (it works fine until you [toggle](https://www.mindstick.com/forum/12682/jquery-toggle-if-statement) this setting) then it appends the AM/PM on the end even though I didn't ask for it:

```
20080927030337 PM
```

Am I doing [something wrong](https://www.mindstick.com/forum/12790/something-wrong-with-gridview) or is this a bug with [firmware](https://www.mindstick.com/articles/13049/can-t-update-netgear-extender-firmware-opt-for-instant-technical-support) 2.1?

Edit 1: Made description clearer

Edit 2 workaround: It turns out this is a bug, to fix it I set the AM and PM [characters](https://answers.mindstick.com/qa/42112/who-is-the-originator-of-avengers-characters) to "":

```
[dateFormatter setAMSymbol:@""];[dateFormatter setPMSymbol:@""];
```


---

Original Source: https://www.mindstick.com/forum/33390/nsdateformatter-am-i-doing-something-wrong-or-is-this-a-bug

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
