Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3362278
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:15:17+00:00 2026-05-18T03:15:17+00:00

I have been trying to wrap my head around NSDate , NSCalendar , NSDateComponents

  • 0

I have been trying to wrap my head around NSDate, NSCalendar, NSDateComponents, NSTimeZone, and NSDateFormatter.

NSDate, NSTimeZone and NSDateFormatter are pretty straightforward. The other classes are not.

I want to get the current Eastern Time (the actual date/time is in EST at the moment the code is run).

Then I want to advance that date by exactly one month, taking into account daylight savings that may (or may not be) in effect.

From what I understand, adding 84600 is the improper way to do this, but I could be wrong.

Can someone please post an example of how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:15:18+00:00Added an answer on May 18, 2026 at 3:15 am

    It’s actually pretty easy:

    NSDate *now = [NSDate date];
    
    NSDateComponents *oneMonth = [[[NSDateComponents alloc] init] autorelease];
    [oneMonth setMonth:1];
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDate *oneMonthFromNow = [calendar dateByAddingComponents:oneMonth toDate:now options:0];
    
    NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
    [df setTimeZone:[NSTimeZone timeZoneWithName:@"America/New_York"]];
    [df setDateStyle:NSDateFormatterMediumStyle];
    [df setTimeStyle:NSDateFormatterMediumStyle];
    
    NSLog(@"Now in New York: %@", [df stringFromDate:now]);
    NSLog(@"One month from now in New York: %@", [df stringFromDate:oneMonthFromNow]);
    

    Edit: That said, your question is phrased a little confusingly. With NSDate, you don’t do calculations in a specific time zone. You also don’t get the “current Eastern Time”. You just get the current point in time (regardless of time zone) and do your calculations on it. The actual conversion to a specific time zone only happens at output (when you display the time to the user, usually in their time zone).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to wrap my head around the concept of semaphores in
I have been trying to wrap my head around this issue for the past
For sometime now, I have been trying to wrap my head around the reason
I have been trying to wrap my head around creating a RESTFul API using
I have been trying to wrap my head around this for a while now
I have been trying to wrap my head around functional programming for a while
I have been trying to wrap my head around why this is happening but
Ok, I have been trying to wrap my head around this http live streaming.
I have been trying to wrap my head around mvvm for the last week
I have been trying to wrap my head around this FXCop violation DoNotDeclareReadOnlyMutableReferenceTypes MSDN:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.