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

  • Home
  • SEARCH
  • 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 8368953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:31:10+00:00 2026-06-09T13:31:10+00:00

I have an app that pulls data from a server where the timestamp is

  • 0

I have an app that pulls data from a server where the timestamp is UTC. My app has to show things on screen based on the current local time. The issue I am running into is the following

If I do this

// the Y M D is fine but time is -8 behind so showing 03:34 instead of 11:34.
NSDate *today = [[NSDate alloc] init]; 

So when I do this

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(start <= %@) AND (room == %@) AND (end >= %@)", today, room, today];

I am not getting the correct results as today when inserted into the NSPredicate is “2012-08-10 03:34:00” but should be “2012-08-10 11:34:00”

I can’t just add 8 hours to the time because the app might be used in different timezones. The only idea is I have is to get the devices timezone figureout how many hours it is behind UTC the add/subtract those hours using NSDateComponents. Is there any easier way by just setting something in CoreData for NSPredicate fetches?

  • 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-06-09T13:31:11+00:00Added an answer on June 9, 2026 at 1:31 pm

    [[NSDate alloc] init] returns the current UTC date and time.

    If you are storing the date to a database or server you should, as a best practice, store the UTC time and always convert to “local” format only when you display in the UI.

    If you need to display it in your UI you should use an NSDateFormatter to properly display it in local time. You can use the NSTimeZone object to determine the local time zone and set your NSDateFormatter with the appropriate time zone.

    Even when you create an NSDate formatted by a “locally configured” NSDateFormatter the underlying date/time is still in UTC.

    If you follow these principles you won’t have any issues with dates in your predicate

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

Sidebar

Related Questions

I have an app that received JSON data from the server. Currently when I
I have a Silverlight Windows Phone 7 app that pulls data from a public
I have built an iPhone app that needs to pull data from a server.
I'm creating an app that pulls data from a web server (MySQL), parses it
I have a little app that pulls data from several API's. In all of
I have an app that needs to pull data from a server and insert
I have been developing an iPhone app which queries a server that relays data
Scenario: I have an application that pulls data from a SQL database as well
My app pulls data from a website which uses Form based authentication. It needs
Have an app that has listings - think classified ads - and each listing

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.