---
title: "How to print NSDate using NSLog?"  
description: "How to print NSDate using NSLog?"  
author: "marcel ethan"  
published: 2015-12-06  
updated: 2015-12-07  
canonical: https://www.mindstick.com/forum/33688/how-to-print-nsdate-using-nslog  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to print NSDate using NSLog?

I want to [print](https://www.mindstick.com/blog/301752/types-of-3d-printing-technology) **NSDate** in **NSLog**, but its not [printing](https://www.mindstick.com/blog/63804/5-ways-you-can-use-printing-in-your-marketing-strategy) [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) correctly.

```
NSDateFormatter *format = [NSDateFormatter new];[format setDateFormat: @"YYYY-MM-DD"];NSDate *date = [NSDate date];NSLog(@"Date: %@",format);
```

Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox), what's [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) in my code..!

## Replies

### Reply by Tarun Kumar

To print date in **NSLog** use **stringFromDate** method of **NSDateFormatter** class.\
Here, we provide the example, change your code by this code:

```
NSDateFormatter *format = [NSDateFormatter new];[format setDateFormat: @"YYYY-MM-DD"];NSLog(@"Date: %@",[format stringFromDate:Your_Date_obj]);
```


---

Original Source: https://www.mindstick.com/forum/33688/how-to-print-nsdate-using-nslog

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
