iOS Development--Timestamp issues

Source: Internet
Author: User

What is a timestamp?

A timestamp (timestamp), usually a sequence of characters that uniquely identifies a moment in time. Digital Timestamp technology is a variant application of digital signature technology.

Thinking: Simply speaking is based on the file hash encryption generated by the digest and time generated time voucher, its value is from 1970 year 1 months 1 days 8 points to the current time total number of milliseconds

How do I convert a timestamp to nsdate in Objective-C?

1 nsstring*str=@ "1283376197"; 2 nstimeintervaltime=[str doublevalue]; 3 nsdate*detaildate=[nsdate datewithtimeintervalsince1970:time]; 4 NSLog (@ "date:%@", [detaildatedescription]);

Thinking: Using this function, the double value of the time stamp is passed to get the nsdate time

How do I convert the current time to a timestamp?

1NSDate *datenow =[nsdate Date];//now time, you can output to see what the format is2Nstimezone *zone =[Nstimezone Systemtimezone];3Nsinteger interval =[Zone Secondsfromgmtfordate:datenow];4NSDate *localedate =[Datenow Datebyaddingtimeinterval:interval];5NSString *timesp = [NSString stringWithFormat:@"%d", (Long) [Localedate timeIntervalSince1970]];6NSLog (@"timesp:%@", TIMESP);//value of time stamp

The timestamp of objective-c is 1000 times times the time stamp of Java, and the timestamp of objective-c is divided by the time stamp of Java by 1000.

iOS Development--Timestamp issues

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.