Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Convert NSDate from local timezone to UTC and vice versa in Swift 3.0

1. To convert UTC(Coordinated Universal Time) to Local timezone func convertToLocalDateFromUTCDate(dateStr : String) -> String { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z" let...

How to find the day of week?

Suppose we want to find the day of the week according to the given date i.e if we want to know the week day of a particular date then the following lines of code will help you to implement this :-   NSDate *date = [NSDate date]; //...

Convert NSDate into UTC

Coordinated Universal Time (UTC) is the standard time zone. All time zones are at some time ahead or behind UTC. If there is a need to convert timeZones of different countries then we can first change the local time to UTC and then to the desired...

How to convert NSDate from local timezone to UTC and vice versa in objc

1. To convert UTC to local time zone - (NSString *)convertLocalDateFromUTCDate:(NSString *)dateStr{ NSDateFormatter *formatter = [self dateFormatter]; [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"]; NSDate *sourceDate...

How to convert from NSSTRING TO NSDATE ?

// date from string NSString *dateString = [NSString stringWithFormat:@"%@",_model.time]; // model.time is the field in which we are fetching the string. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFo...

Array of dates between two dates

Hello Friends, To create an array of dates between two dates you may use the following code: 1.Create an NSMutableArray NSMutableArray *datesArray = [NSMutableArray new];   2.Set the date formatter according to your requi...

Compare two dates in iOS

To compare two dates we can use the following code : NSComparisonResult result = [mydate1 compare:mydate2]; //where mydate1 and mydate2 are two dates we want to compare. if (result == NSOrderedDescending) { //mydate1 is later than myda...

Some helpful date related code

Get a date after n days -(NSDate*)getNextDayAfterDays:(int)numOfDays from:(NSDate*)date { NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *offsetComponents = [[NSDateCom...
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: