NSTimeZone: Any difference between “UTC” and “GMT”?

According to the docs, CFTimeZone (and by extension, NSTimeZone) uses time zone names, abbreviations, GMT offset, and DST information from the TZ (or “Olsen”) Database. Looking at the source, you’ll see that while semantically “GMT” and “UTC” are quite distinct, in practice they’re no different: “GMT” is just a zero offset timezone. Update: While this … Read more

Detect if time format is in 12hr or 24hr format

I figured it out, its pretty easy. I just added this code to viewDidLoad : NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setLocale:[NSLocale currentLocale]]; [formatter setDateStyle:NSDateFormatterNoStyle]; [formatter setTimeStyle:NSDateFormatterShortStyle]; NSString *dateString = [formatter stringFromDate:[NSDate date]]; NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]]; NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]]; BOOL is24h = (amRange.location == NSNotFound && pmRange.location == … Read more

How to get a user’s time zone?

edit/update: Xcode 8 or later • Swift 3 or later var secondsFromGMT: Int { return TimeZone.current.secondsFromGMT() } secondsFromGMT // -7200 if you need the abbreviation: var localTimeZoneAbbreviation: String { return TimeZone.current.abbreviation() ?? “” } localTimeZoneAbbreviation // “GMT-2” if you need the timezone identifier: var localTimeZoneIdentifier: String { return TimeZone.current.identifier } localTimeZoneIdentifier // “America/Sao_Paulo” To know … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)