简体   繁体   中英

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

on label. What do I need to program to make only time (HH:MM) show on label. My specific country

timezone is Bangkok, Thailand (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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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