【问题标题】:Current time (specific timezone) on a label标签上的当前时间(特定时区)
【发布时间】:2014-11-08 07:44:57
【问题描述】:

我正在第一页上制作一个 iOS 应用程序,我想显示特定国家时区的当前时间

在标签上。我需要进行什么编程才能使标签上仅显示时间(HH:MM)。我的特定国家

时区是泰国曼谷 (GMT+7)。谢谢你的帮助! :)

This is screen shot link to the label. I haven't program anything yet 

https://www.dropbox.com/s/wnyq0m9s9dkk0eb/Screen%20Shot%202014-11-08%20at%202.41.50%20PM.png?dl=0

【问题讨论】:

    标签: ios xcode label nstimer nstimezone


    【解决方案1】:
    // retrive the time regarding info.
    NSDate *t = [NSDate date];
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    // line below formats your time.
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    // now get the current time fomated 
    NSString *ct = [df stringFromDate:t];
    NSLog(@"%@",ct);
    
    // set your label
    self.lbl.text = ct;
    

    【讨论】:

      猜你喜欢
      • 2012-03-23
      • 2017-09-18
      • 2015-01-01
      • 2020-05-27
      • 2019-06-14
      • 2011-03-15
      • 2019-10-01
      • 2017-04-30
      • 2011-11-07
      相关资源
      最近更新 更多