The number of seconds that the IOS current time is past a certain point in time

Source: Internet
Author: User

Do Bluetooth development time to set the synchronization time, in seconds, the current time distance from 2000-01-01 00:00:00 seconds. Search the Internet for a long time of the data have not found the right, and then studied a bit. The specific wording is as follows:

NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];

[Dateformatter setdateformat:@ "Yyyy-mm-dd HH:mm:ss"]; Set the time format

Nstimezone *timezone = [Nstimezone timezonewithname:@ "GMT"];

[Dateformatter Settimezone:timezone]; Set the time zone

NSString *somedaystr= @ "2000-01-01 00:00:00"; Set a point in the past for example: 2000-01-01 00:00:00

NSDate *somedaydate = [Dateformatter datefromstring:somedaystr];

NSDate *currentdate = [NSDate Date];

Nstimeinterval Time=[currentdate Timeintervalsincedate:somedaydate]; Number of seconds 00:00:00 current time distance 2000-01-01

NSLog (@ "%lld", (Long long int) time);

The number of seconds that the IOS current time is past a certain point in time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.