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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:01:30+00:00 2026-05-26T10:01:30+00:00

In my iPhone application, I somehow need the time value and get it like:

  • 0

In my iPhone application, I somehow need the time value and get it like:

//Get the full time here
NSDate *now = [NSDate date];
//Seperate as time and date
NSArray *arr = [[[NSString alloc] initWithFormat:@"%@",now] componentsSeparatedByString:@" "];
//Get the time value
NSString *timeOnly = [arr objectAtIndex:1];
//Seperate it like hour, minute and second values
NSArray *timeOnlyArray = [timeOnly componentsSeparatedByString:@":"];
NSInteger hour = [[timeOnlyArray objectAtIndex:0] intValue];
NSInteger minute = [[timeOnlyArray objectAtIndex:1] intValue];

It all works fine except one thing: Even though my computer’s and my simulator’s times are set to my local time (GMT +2) the values I get while debugging on simulator are GMT time (2 hours earlier than my local).

That’s fine, I can simply add 2 to my hour value but I don’t know if it will be same on device. If I publish it this way, will it work same on device? Or should I add 2 hours because the application will look to GMT time in the real device too?

  • 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-26T10:01:30+00:00Added an answer on May 26, 2026 at 10:01 am

    You might want to look into the NSDateFormatter class (as written in the AppleDocs: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html)
    When you’ve done that read up here: Convert UTC NSDate to local Timezone Objective-C

    Just adding the 2 to the hours-value isn’t good practice. How will you manage with daylight saving time? Or when someone in another timezone will use your app?

    Using the NSDateFormatter will probably be the best solution for you.

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

Sidebar

Related Questions

My iPhone application downloads large files from the internet (videos, for instance). I'd like
My iPhone application has several views and some viewControllers for that views. I need
I have created an iPhone application based on an OpenGL view. Now I would
I have converted an iPhone application using the wizard like thing in XCode into
I have an iPhone application using UINavigationController and would like to customize the elements
I need to add an in-app purchase option to my iPhone application. All it
my iPhone application should store some data persistantly by using Core Data functionality. Here
I would like to start testing my application on my iPhone. However, I have
I am developing an iPhone application that persists data to a SQLite3 database. For
I am developing iPhone application and In that application I've one TableViewController , and

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.