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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:18:49+00:00 2026-05-25T19:18:49+00:00

I am using a web services which returns a JSON WCF DateTime. The string

  • 0

I am using a web services which returns a JSON WCF DateTime.

The string goes like \/Date(1316397792913+0800)\/

I am interested in extracting out the 1316397792 which is the time since 1st Jan 1970 in seconds. So that I can use the NSDate timeIntervalSince1970 method to get the present time. I cropped out the last 3 digits as it’s in milliseconds and the timeIntervalSince1970 takes in seconds.

Here’s what I am currently doing which does not work for dates somewhere before 2001 which has a time interval in ms since 1970 less than 10 characters.

NSString *dateString = @"\/Date(1316397792913+0800)\/";
    NSLog(@"dateString :%@", dateString);

    NSDate *date = [NSDate dateWithTimeIntervalSince1970:
                    [[dateString substringWithRange:NSMakeRange(6, 10)] intValue]];
    NSLog(@"NSDate:%@", date);

dateString :/Date(1316397792913+0800)/
NSDate:2011-09-19 02:03:12 +0000

Therefore, I need a better work around playing with the dateString which does not assume everytime we will be feteching 10 characters.

  • 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-25T19:18:50+00:00Added an answer on May 25, 2026 at 7:18 pm

    You can simply get the substring between the index of ( and the index of +. Something like:

    NSRange begin = [dateString rangeOfString:"("];
    NSRange end = [dateString rangeOfString:"+"];
    NSString* milliSecondsSince1970 = [dateString substringWithRange:NSMakeRange(begin.location + 1, end.location - begin.location - 1)];
    

    P.S: Check for the one off error.

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

Sidebar

Related Questions

I have a .net JSON web service which returns a json string when queried.
I am developing some client side Javascript that is using some JSON web services
I would like to create a service which returns a simple string. So far
I have created a web service which has a couple of methods developed using
I wrote a simple web service in C# using SharpDevelop (which I just got
I'm using Web Services Enhancements 3.0 to call a web-service from an ASP.NET application
I'm trying to upload documents to SharePoint using web services attaching custom metadata to
I'm using Exchange Web Services to Find, Create, Update, and Delete appointments from the
For example: using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Web.Script.Serialization;
I'm using Fedex's web services and getting an annoying error right up front before

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.