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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:22:48+00:00 2026-06-07T15:22:48+00:00

Please note that update 3 is probably most relevant Im setting a NSTimeInterval property

  • 0

Please note that update 3 is probably most relevant

Im setting a NSTimeInterval property of a managed object with an nsdate object using setValue:forKey:

When i attempt to get the value I get weird stuff, at runtime this

NSLog(@"[managedObject valueForKey:@\"startTime\"] : %@, [NSDate dateWithTimeIntervalSince1970:[managedObject startTime]]: %@",
[managedObject valueForKey:@"startTime"],[NSDate dateWithTimeIntervalSince1970:[managedObject startTime]]);

Returns

[managedObject valueForKey:@"startTime"] : 2012-07-14 08:13:05 +0000,
[NSDate dateWithTimeIntervalSince1970:[managedObject startTime]]: 1981-07-14 08:13:05 +0000

Update 1
The value returned by [managedObject valueForKey:@"startTime"] is correct. However I would prefer to use [NSDate dateWithTimeIntervalSince1970:[managedObject startTime]] or something similar so that it is more strongly typed.

I believe [managedObject startTime] returns an incorrect value => 363954111.000000 .
However i set it with something like this:

managedObject setValue:1342261311 forKey:@"startTime"

It is worth noting that I am unsure whether this is incorrect because [managedObject valueForKey:@"startTime"] returns a correct NSDate object.

Update 2
I’ve logged the double values returned by KVC and . syntax.

managedObject.startTime = 363954111.000000
valueForKey timeIntervalSince1970 = 1342261311.000000

Update 3
Okay, I’ve set up a test, start time is set like this entity.startTime = [[NSDate dateWithTimeIntervalSince1970:1342261311] timeIntervalSince1970]; and end time is set like this [entity setValue:[NSDate dateWithTimeIntervalSince1970:1342261311] forKey:@"endTime"];

When i write them to log i get this start = 1342261311.000000, end = 363954111.000000

It seems that the NSDate object is being unwrapped incorrectly, has anyone seen this before?

  • 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-07T15:22:49+00:00Added an answer on June 7, 2026 at 3:22 pm

    It was a problem with the difference in epochs. NSDate uses Jan 1 2001 as an epoch. So when I was getting the value I was using the unix epoch (1970). That gave me a difference in values.

    When KVC unwraps and wraps NSTimeInterval with a NSDate object it uses the NSDate 2001 epoch.

    So instead of using dateWithTimeIntervalSince1970
    I used dateWithTimeIntervalSinceReferenceDate when getting the value.

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

Sidebar

Related Questions

How can I convert Persian date to Gregorian date using System.globalization.PersianCalendar? Please note that
For whatever reason - my update panel is not updating. Now please note that
Please note that Object.Watch and Object.Observe are both deprecated now (as of Jun 2018).
UPDATE: Please note that I am seeing this issue only in Chrome (latest version).
I've provided an update for an application that use keychain in iOS. Please note
Please note that I'm not asking how but why. And I don't know if
[Please note that this is a different question from the already answered How to
(Please note that I have seen a similar question on StackOverflow recently, however I
Please note that this is not homework and i did search before starting this
Please note that I did ask this on Super User and received absolutely no

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.