I have a string like this
NSString *datestr = @"2013-08-06T03:51:54+00:00";
I try to set dateformat as below:
NSDateFormatter *dformat = [[NSDateFormatter alloc]init];
[dformat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
NSDate *date = [dformat dateFromString:datestr];
But the date will be nil, so, can anyone tell me how to set the dateformat, thx!
Once the General settings page is open, tap on Language & Region. On the Language & Region page, you'll find multiple options like Region, Calendar, Temperature, Measurement System, First Day of Week, and Date Format.
On your Mac, choose Apple menu > System Settings, click General in the sidebar, then click Language & Region on the right. (You may need to scroll down.) Click the pop-up menu next to Region, then choose a geographic region to use the region's date, time, number, and other formats.
Using the Repeat actionPlace the actions that you want to repeat between the Repeat and End Repeat markers, then specify the number of times you want the action to repeat. When the shortcut runs, the actions placed between the markers loop the number of times that you specify.
Try this:
NSDateFormatter *dformat = [[NSDateFormatter alloc]init];
[dformat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
NSDate *date = [dformat dateFromString:datestr];
Add ZZZ
to the end of your formatter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With