Get the Day from the date in iOS sdk

后端 未结 7 475
无人共我
无人共我 2021-01-16 12:36

In my app, want to get the day (i.e. Sunday, Monday,etc.) from the date.

My code is as follow:

NSDate *currentDate = [NSDat         


        
相关标签:
7条回答
  • 2021-01-16 13:33

    you face problem because it take local time zone

    try this

      NSDateFormatter *dateformate = [[NSDateFormatter alloc] init] ;
     [dateformate setTimeZone:[NSTimeZone timeZoneWithName:@"Australia/Sydney"]];
     [dateformate setDateFormat:@"EEEE"];
      NSLog(@"%@", [dateformate stringFromDate:[NSDate date]]);
      NSLog(@"%@", [NSTimeZone knownTimeZoneNames]);
    

    set time zone that you required.it may work and help you.

    similar problem in NSCalendar first day of week link refer it.also may help you.

    0 讨论(0)
提交回复
热议问题