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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:55:20+00:00 2026-06-07T03:55:20+00:00

i have a methods : – (NSString *)intervalSinceNow: (NSString *) theDate { NSDateFormatter *date=[[NSDateFormatter

  • 0

i have a methods :

- (NSString *)intervalSinceNow: (NSString *) theDate 
{



NSDateFormatter *date=[[NSDateFormatter alloc] init];
[date setDateFormat:@"yyyy-MM-dd HH:mm "];
NSDate *d=[date dateFromString:theDate];

NSTimeInterval late=[d timeIntervalSince1970]*1;


NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval now=[dat timeIntervalSince1970]*1;
NSString *timeString=@"";

NSTimeInterval cha=now-late;

if (cha/3600<1) {
    timeString = [NSString stringWithFormat:@"%f", cha/60];
    timeString = [timeString substringToIndex:timeString.length-7];
    timeString=[NSString stringWithFormat:@"%@m before", timeString];

}
if (cha/3600>1&&cha/86400<1) {
    timeString = [NSString stringWithFormat:@"%f", cha/3600];
    timeString = [timeString substringToIndex:timeString.length-7];
    timeString=[NSString stringWithFormat:@"%@ hour before", timeString];
}
if (cha/86400>1)
{
    timeString = [NSString stringWithFormat:@"%f", cha/86400];
    timeString = [timeString substringToIndex:timeString.length-7];
    timeString=[NSString stringWithFormat:@"%@ day before", timeString];

}

return timeString;
}

when i call intervalSinceNow(2012-07-04T00:16:12Z) it give me 15525 day before,how to solves,thank you?

  • 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-07T03:55:22+00:00Added an answer on June 7, 2026 at 3:55 am

    It’s best not to even try to do these calculations yourself. You have no idea what calendar system the local user is using, among other things.

    The steps to do what you want on the system are as follows:
    – Convert the ISO8601 datetime to an instance of NSDate
    – Display the NSDate in the user’s locale and local time zone

    These steps can be accomplished by using two NSDateFormatter objects. One set up to convert the datetime string into an NSDate and configured for Zulu and the other to format the date for the user’s current locale and time zone. The default NSDateFormatter object will already be configured for the user’s current settings.

    All you need to do in code is something like this:

    - (NSString*)localDateStringForISODateTimeString:(NSString*)ISOString
    {
      // Configure the ISO formatter
      NSDateFormatter* isoDateFormatter = [[NSDateFormatter alloc] init];
      [isoDateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
      [isoDateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
    
      // Configure user local formatter (configure this for how you want
      // your user to see the date string)
      NSDateFormatter* userFormatter = [[NSDateFormatter alloc] init];
      [userFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    
      // Convert the string -- this date can now also just be used
      // as the correct date object for other calculations and/or
      // comparisons
      NSDate* date = [isoDateFormatter dateFromString:ISOString];
    
      // Return the string in the user's locale and time zone
      return [userFormatter stringFromDate:date];
    }
    

    If you print or display the string returned from here now, the example string you provided “2012-07-04T00:16:12Z” would display for me (in New York) as “2012-07-03 20:16” using the code above.

    EDIT: I should note that the above code assumes an ARC environment. If you’re not using ARC, add autorelease messages to the creation of the two date formatters, or they will be leaked.

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

Sidebar

Related Questions

I have methods in all of my models that look like this: def formatted_start_date
In C# I have methods that use [WebMethod(EnableSession = true)] I consume them in
In my application I have methods which returns a control (checkbox, radiobutton, textbox) but
if I have methods like function getVar1(){ return $this->var1; } function getVar2(){ return $this->var2;
I'm working on a game engine in C++ and I have methods like setColour
String is a module and str is a type. I found str have methods,
I have multiple calls to methods in a 3rd party library. These methods have
I have two methods declared public void MethodA(object o, Action<string> action) { } public
I have async methods that returns an objects public static IEnumerable<Users.User> GetUsers(IEnumerable<string> uids, Field
I have this methods getParam public int getParam(String paramName){ if(paramName.equals(Balls and net)){ expressionParam=1; }

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.