How do I get weekday and/or name of month from a NSDate variable?

There is no need to manually convert to the Swedish words. iPhone will do it for you. Try this: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateFormat = @”yyyyMMdd”; NSDate *date = [dateFormatter dateFromString:@”20111010″]; // set swedish locale dateFormatter.locale=[[NSLocale alloc] initWithLocaleIdentifier:@”sv_SE”]; dateFormatter.dateFormat=@”MMMM”; NSString *monthString = [[dateFormatter stringFromDate:date] capitalizedString]; NSLog(@”month: %@”, monthString); dateFormatter.dateFormat=@”EEEE”; NSString *dayString = [[dateFormatter … Read more

NSString to NSDate

You can’t invent format string syntax and expect it to work; you need to actually use a documented format. (Seriously, “MM” meaning “month”, “minute” and “GMT offset minutes” all at the same time?) As the documentation points out, the 10.4 formatters use Unicode format strings. Try “yyyy-MM-dd HH:mm:ss ZZZ” instead. Also, Objective-C source is ASCII. … Read more

How to convert NSDate in to relative format as “Today”,”Yesterday”,”a week ago”,”a month ago”,”a year ago”?

For simplicity I’m assuming that the dates you are formatting are all in the past (no “tomorrow” or “next week”). It’s not that it can’t be done but it would be more cases to deal with and more strings to return. You can use components:fromDate:toDate:options: with whatever combination of date components you are looking for … Read more

How do I convert a date/time string into a different date string?

This may be useful for who want to use dateformatter.dateformat; if you want 12.09.18 you use dateformatter.dateformat = “dd.MM.yy” Wednesday, Sep 12, 2018 –> EEEE, MMM d, yyyy 09/12/2018 –> MM/dd/yyyy 09-12-2018 14:11 –> MM-dd-yyyy HH:mm Sep 12, 2:11 PM –> MMM d, h:mm a September 2018 –> MMMM yyyy Sep 12, 2018 –> MMM … Read more

Why does NSDateFormatter return nil date for these 4 time zones?

I have a suspicion. Only a suspicion, but a pretty strong one. That value represents October 19th 2064. The Brazilian time zones observe daylight saving time starting at local midnight – that’s when their clocks go forward, so midnight itself doesn’t exist. October 19th is one of those transitions. Here’s some sample code using Noda … Read more

How do I get the current Date in short format in Swift

Xcode 11 or later • Swift 5.1 or later extension TimeZone { static let gmt = TimeZone(secondsFromGMT: 0)! } extension Locale { static let ptBR = Locale(identifier: “pt_BR”) } extension Formatter { static let date = DateFormatter() } extension Date { func localizedDescription(date dateStyle: DateFormatter.Style = .medium, time timeStyle: DateFormatter.Style = .medium, in timeZone: TimeZone … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş