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 3240022
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:02:16+00:00 2026-05-17T18:02:16+00:00

I’m trying to code part of a program that allows users to set up

  • 0

I’m trying to code part of a program that allows users to set up one or more alarms that will remind them to launch the application and do something at certain times of day.

I basically understand that I need to use local notifications, but I’m having a hard time coming up with the best way to represent a time of day in my application settings in the proper manner.

For example, I tried this sort of thing to represent 8:00 AM

[NSDate dateWithTimeIntervalSince1970:(8 * 60 * 60)]

But the problem is that this means 8 AM GMT and not in the local timezone, so when I pass this to NSDateFormatter I end up with 3:00AM for example in my time zone.

Basically I know I need to do something with NSCalendar, NSDate, and NSTimeInterval, and perhaps NSDateComponents but I can’t seem to come up with the simplest approach to this that will allow me to calculate scheduling NSDates for iOS local notifications.

So I guess what this boils down to is, how do I represent 8:00 AM for example in the system timezone in such a way that NSDateFormatter will correctly format it as a local time?

Seems like I should be able to figure this out but maybe it’s just too late in the evening….

  • 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-17T18:02:17+00:00Added an answer on May 17, 2026 at 6:02 pm

    For example, I tried this sort of thing to represent 8:00 AM

    [NSDate dateWithTimeIntervalSince1970:(8 * 60 * 60)]
    

    But the problem is that this means 8 AM GMT and not in the local timezone…

    No, the problem is that that means 8 AM GMT on January 1st, 1970.

    An NSDate object is not expressed in any calendar or time zone. An NSDate object is a moment in history, nothing more. You need a calendar object to convert it to or from a calendar representation (e.g., year, month, day-of-month, hour, minute, second), or a date formatter to convert it to or from a string representation (e.g., “2010-10-15T22:29:27-0700”).

    If you want to compute the NSDate for 8 AM today, create an NSCalendar object and ask it when that is. Use components:fromDate: to turn right now ([NSDate date]) into date components, then overwrite the hour, minute, and second and convert back.

    A UIDatePicker (such as you probably should present to the user to enable them to choose the date and time of their alarm) will give you an NSDate; there is no need to perform any sort of conversion or manipulation on it. The most you might need to do is subtract some time if the user chose to have you ring the alarm that much time ahead of the actual event.

    So I guess what this boils down to is, how do I represent 8:00 AM for example in the system timezone in such a way that NSDateFormatter will correctly format it as a local time?

    An NSDateFormatter takes an NSDate, and, as I said, NSDates aren’t in a time zone. As you saw, your date formatter will use the user’s time zone by default (although this isn’t explicitly stated in the documentation). For the date formatter to use something else, you would have to have told it to do so.

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

Sidebar

Related Questions

No related questions found

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.