iphone获取当前时间
2012-03-29 09:33
183 查看
-(void)GetTime:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool
alloc] init];
NSDateFormatter *formatter =[[NSDateFormatter
alloc] init];
NSDate *date = [[NSDate
alloc]init];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss "];//mm
NSTimeZone* timeZone = [NSTimeZone
timeZoneWithName:@"Asia/Shanghai"];
[formatter setTimeZone:timeZone];
NSString *locationtime = [formatter
stringFromDate:date];
currenttime = locationtime;
CurrenttimeLabel.text =
currenttime;
CurrenttimeLabel.enabled =
NO;
[date release];
[formatter release];
[pool release];
}
- (void)viewDidLoad
{
[NSThread detachNewThreadSelector:@selector(Gettime:)toTarget:selfwithObject:nil];
}
{
NSAutoreleasePool *pool = [[NSAutoreleasePool
alloc] init];
NSDateFormatter *formatter =[[NSDateFormatter
alloc] init];
NSDate *date = [[NSDate
alloc]init];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss "];//mm
NSTimeZone* timeZone = [NSTimeZone
timeZoneWithName:@"Asia/Shanghai"];
[formatter setTimeZone:timeZone];
NSString *locationtime = [formatter
stringFromDate:date];
currenttime = locationtime;
CurrenttimeLabel.text =
currenttime;
CurrenttimeLabel.enabled =
NO;
[date release];
[formatter release];
[pool release];
}
- (void)viewDidLoad
{
[NSThread detachNewThreadSelector:@selector(Gettime:)toTarget:selfwithObject:nil];
}
相关文章推荐
- 如何获取当前系统时间 iphone开发 ios编程
- iPhone开发--获取当前时间与2001年1月1日的时间差以毫秒为单位
- iphone开发获取当前系统时间所在时区
- iOS获取当前时间日期
- shell获取系统当前时间并格式化
- js 获取当前时间并格式化
- java如何获取当前时间的方法汇总
- 【Objective-C】NSDate详解及获取当前时间等常用操作
- 判断手机号的输入是否正确、获取当前的时间以及显示距离上次发布有多久的时间
- SQL:GETDATE() 获取当前时间
- java中获取当前时间
- 获取当前时间
- Java 获取当前日期和时间
- Js获取当前日期时间及其它操作
- freemarker 获取 当前时间
- 动态获取系统当前时间
- 获取iphone当前的语言设置
- PHP中当前时间的获取
- C/C++获取当前系统时间
- C# 获取两个时间段之间的所有时间与获取当前时间所在的季度开始和结束时间