String zonestr timestamp #pragma mark timestamp turns into time
-(nsstring *) Timestampintotime: (nsstring *) zonestr{
//timestamp string converted to date string
Long long index = [zonestr longlongvalue];
nsdate *sinedate = [nsdate dateWithTimeIntervalSince1970: index/ ];
nsdateformatter *dateformatter = [[nsdateformatter alloc] init];
//yyyy mm month dd Day HH24 hours HH12 hours mm minutes ss seconds mmmm month
[dateformatter setdateformat:@ "Yyyy-mm-dd HH:mm:ss MMMM"];
//date turn into time
nsstring *datastring = [dateformatter stringfromdate: sinedate];
return datastring;
}
A string that #pragma mark time to turn into a timestamp
-(nsstring *) timestamp{
//Get the system time
nsdate *date = [nsdate date];
//time stamp
long secondtimezone = [date timeIntervalSince1970]*;
//timestamp turns into a string
nsstring *zonestr = [nsstring stringwithformat:@ "%@"@ (secondtimezone )];
return zonestr;
}
#pragma mark Format time
-(nsstring *) formattedtime{
//Get the system time
nsdate *date = [nsdate date];
//Time to format the system
nsdateformatter *dateformatter = [[nsdateformatter alloc] init];
//yyyy mm month dd Day HH24 hours HH12 hours mm minutes ss seconds mmmm month
[dateformatter setdateformat:@ "Yyyy-mm-dd HH:mm:ss MMMM"];
//date turn into time
nsstring *datastring = [dateformatter stringfromdate:d ate];
return datastring;
}
#pragma mark to format a string of time datastr for the specified time zone
-(nsstring *) Timezonetimeformat: (nsstring *) datastr{
nsdateformatter *dateformatter = [[nsdateformatter alloc] init];
[Dateformatter Setdateformat:@ "Yyyy-mm-dd hh:mm"];
nsdate *date = [dateformatter datefromstring:d atastr];
Dateformatter. TimeZone = [nstimezone timezonewithname:@ "Asia/shanghai"];
nsstring *strdate = [dateformatter stringfromdate:d ate];
return strdate;
}
Basic use of IOS nsdate dates