Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

聊天时间不准确的问题 #1

Open
xiaobeifeng opened this issue Dec 13, 2018 · 1 comment
Open

聊天时间不准确的问题 #1

xiaobeifeng opened this issue Dec 13, 2018 · 1 comment

Comments

@xiaobeifeng
Copy link

在NSTimer+SSAdd分类中

//时间戳转换成时间(YYYY-MM-dd HH:mm:ss)
+ (NSString *)getTimeWithTimeStamp:(long)timeStamp{
    // 格式化时间
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    
    // 毫秒值转化为秒 /1000
    NSDate* date = [NSDate dateWithTimeIntervalSince1970:timeStamp];
    NSString* dateString = [formatter stringFromDate:date];
    return dateString;
}

时区的转化好像有点问题,显示的依旧是零时区时间,改成

 formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8*3600];

就正常显示了

作者有时间看下这里

感谢开源~

@Soldoros
Copy link
Owner

Soldoros commented Jun 6, 2019

你好,静态版本的时间没有过多处理,已更新网易云IM ,你可以下载最新版本!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants