What is a timestamp?
time Stamp ( timestamp ), which is typically a sequence of characters. 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 certificate, its value is from 1970 years 1 Month 1 Day 8 The total number of milliseconds to point to today's time
in Objective - C How do I convert timestamps to nsdate?
Nsstring*[email protected] "1283376197";
Nstimeintervaltime=[str Doublevalue];
Nsdate*detaildate=[nsdate Datewithtimeintervalsince1970:time];
NSLog (@ "date:%@", [detaildatedescription]);
think: Use 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?
nsdate *datenow =[nsdate Date]; // Today's Time , you can output to see what the format is
Nstimezone *zone = [nstimezone systemtimezone];
nsinteger interval = [zone secondsfromgmtfordate:d Atenow];
nsdate *localedate = [Datenow datebyaddingtimeinterval: interval];
NSString *TIMESP = [nsstring stringwithformat: @ "%d", (long) [Localedate timeIntervalSince1970]];
NSLog (@ "timesp:%@", TIMESP); // value of time stamp
think: The interval of the standard time based on the current time and the system's time zone, and then the time after validation lo caledate , and finally [localedate timeIntervalSince1970] get the time after the validation and 1970 the difference between the years and the time stamp
How to format output nsdate?
Nsdateformatter*formatter = [[NSDateFormatter alloc]init];
[formattersetdateformat:@ "yyyy mm month DD Day"];
NSDate *date =[formatter Stringfromdate:detaildate];
NSLog (@ "date:%@", date);
think: Create a NSDateFormatter class, and then pass a nsdate on it.
"Yyyymmddhhmmss" represents the seconds of the month and day
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Objective-c conversion and time of timestamp conversions