简体   繁体   English

标签上的当前时间(特定时区)

[英]Current time (specific timezone) on a label

I am making an iOS app on the first page I want to show current time for specific country time zone 我在首页上制作了一个iOS应用,我想显示特定国家/地区时区的当前时间

on label. 在标签上。 What do I need to program to make only time (HH:MM) show on label. 我需要编程什么才能仅在标签上显示时间(HH:MM)。 My specific country 我的特定国家

timezone is Bangkok, Thailand (GMT+7). 时区是泰国曼谷(GMT + 7)。 Thanks for your help! 谢谢你的帮助! :) :)

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 https://www.dropbox.com/s/wnyq0m9s9dkk0eb/Screen%20Shot%202014-11-08%20at%202.41.50%20PM.png?dl=0

// 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM