---
title: "How to convert day of the year to date in ios?"  
description: "How to convert day of the year to date in ios?"  
author: "marcel ethan"  
published: 2014-11-11  
updated: 2014-11-12  
canonical: https://www.mindstick.com/forum/2560/how-to-convert-day-of-the-year-to-date-in-ios  
category: "iphone"  
tags: ["ios", "objective c", "date", "time"]  
reading_time: 1 minute  

---

# How to convert day of the year to date in ios?

Currently I [failed](https://www.mindstick.com/forum/160484/error-failed-to-launch-debug-adapter-additional-information-may-be-available-in-the-output-window) to [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) a [day of the year](https://answers.mindstick.com/qa/39873/what-day-of-the-year-is-known-as-black-thursday-because-on-this-date-the-first-sign-of-the-end-of-the-bull-market-came) [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) to a formatted [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) / [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) like **mm-dd**. I tried some different solution approaches, including most of the [solutions](https://www.mindstick.com/articles/12807/product-searching-issues-and-solutions-for-ecommerce-store-advanced-search-autocomplete-suggest) which are posted here - without success.

I expect this: Today is the **359** day of the year - and it should be converted to **12-25**

## Replies

### Reply by Takeshi Okada

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents* components = [[NSDateComponents alloc] init];

[components setDay:359];

[components setYear:2013];

[components setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];

NSDate* day359 = [gregorian dateFromComponents:components];

output

2013-12-25 00:00:00 +0000


---

Original Source: https://www.mindstick.com/forum/2560/how-to-convert-day-of-the-year-to-date-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
