NSDateFormatter *date=[[nsdateformatteralloc]init];
[Date setdateformat:@ "Yyyy-mm-dd HH:mm:ss"];
nsdate *d=[datedatefromstring: thedate];
nstimeinterval late=[dtimeIntervalSince1970]*1;
nsdate* dat = [nsdatedatewithtimeintervalsincenow: 0];
nstimeinterval now=[dattimeIntervalSince1970]*1;
nsstring *timestring=@ "";
nstimeinterval cha=now-late;
if (cha/3600<1) {
TimeString = [nsstringstringwithformat:@ "%f", cha/];
TimeString = [timestringsubstringtoindex: timestring. Length-7];
int num= [timestringintvalue];
if (Num <=1) {
TimeString = [nsstringstringwithformat:@ " just ..."];
}Else{
TimeString = [nsstringstringwithformat:@ "%@ minutes ago ", timestring];
}
}
if (cha/3600>1&&cha/86400<1) //86400=1 days
{
TimeString = [nsstringstringwithformat:@ "%f", cha/3600];
TimeString = [timestringsubstringtoindex: timestring. Length-7];
timestring=[nsstringstringwithformat:@ "%@ hours ago ", timestring];
}
if (cha/86400>1)
{
TimeString = [nsstringstringwithformat:@ "%f", cha/86400];
TimeString = [timestringsubstringtoindex: timestring. Length-7];
int num=[timestringintvalue];
if (num<2) {
timestring=[nsstringstringwithformat:@ " yesterday "];
}Elseif (num==2) {
TimeString = [nsstringstringwithformat:@ " the day before yesterday "];
}Elseif (num>2&&num<7) {
TimeString = [nsstringstringwithformat:@ "%@ days ago ", timestring];
}Elseif (num >=7 && num <=) {
TimeString = [nsstringstringwithformat:@ "1 weeks ago "];
}Elseif(num > && num <=365) {
int month=cha/(86400*);
timestring=[nsstringstringwithformat:@ "%d", month];
TimeString = [nsstringstringwithformat:@ "%@ weeks ago ", timestring];
}Elseif (num >365) {
int year=cha/(86400*365);
timestring=[nsstringstringwithformat:@ "%d", year];
TimeString = [nsstringstringwithformat:@ "%@ years ago ", timestring];
}
}
iOS converts standard time to timestamp