NSDate 转 RFC 2822 日期格式 [英] NSDate to RFC 2822 Date format

查看:50
本文介绍了NSDate 转 RFC 2822 日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何有效的方法可以将 NSDate 转换为 RFC 2822 日期格式字符串?我想使用这个字符串来创建一个 NSURLRequest 并设置If-Modified-Since"头字段的值.

Is there any efficient way to convert an NSDate to RFC 2822 Date format string ? I want to use this string to create an NSURLRequest and set the value of "If-Modified-Since" header field.

推荐答案

尝试使用 NSDateFormatter

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // maybe there exist a new-method now
dateFormatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss Z"; //RFC2822-Format
NSString *dateString = [dateFormatter stringFromDate:myDate];

这篇关于NSDate 转 RFC 2822 日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆