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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:31:19+00:00 2026-05-26T02:31:19+00:00

We have .NET code (C#) that writes to a SQLite database, which is then

  • 0

We have .NET code (C#) that writes to a SQLite database, which is then read by an iOS (iPhone) app with objective-c.

The date format used in SQLite is NSTimeInterval (to NSDate with dateWithIntervalSince1970) because it’s efficient on the iPhone.

How can .NET DateTime be converted to NSTimeInterval so that when it is extracted with dateWithIntervalSince1970 the date is correct?

Notes:
1) I tried to search on how NSTimeInterval works fundamentally but only find this opaque documentation:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html

2) Although C# code would be ideal I’d be happy with pseudo-code that goes from 3 ints (year/month/day) to a double.

  • 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-26T02:31:20+00:00Added an answer on May 26, 2026 at 2:31 am

    I think you mean NSTimeInterval. NSTimeInterval represents a span of time, in seconds, so its logical equivalent in .NET is System.TimeSpan rather than System.DateTime. But, if you specify it as the span of time since January 1, 1970 00:00:00 GMT, which is what you get with -timeIntervalSince1970, then the conversion between it and System.DateTime becomes possible.

    To convert between System.DateTime and a POSIX timestamp (which is what NSTimeInterval is in this situation, plus subsecond precision), you probably want something like this:

    DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
    DateTime dt = ...;
    double intervalSince1970 = (dt - unixEpoch).TotalSeconds;
    

    To go the other way:

    DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
    double intervalSince1970 = ...;
    DateTime dt = unixEpoch + TimeSpan.FromSeconds(intervalSince1970);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some existing code that retrieves data from a database using ADO.NET that
We have some legacy ASP.NET code that detects if a request is secure, and
I have a line of C# in my ASP.NET code behind that looks like
I have an asp.net web page with a ton of code that is handled
I have the following JQuery code that worked perfect in C#/Asp.net 2.0 to call
I have a normal asp.net page containing some code that I want to measure
Does anyone have some code that will take a TimeZoneInfo field from .NET and
We have taken over some .NET 1.1 Windows Service code that spawns threads to
Is there a tool that analyses .NET code and finds race conditions? I have
NET and VB.net code behind. I have a classic ASP page that connects to

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.