Featured
-
How Regression Testing Detects Integral Errors In Business Processes
Humans are forever changing and evolving and so to
by kristina.rigina -
Get Display Banner Advertising Opportunity on FindNerd Platform
“Do you have a product or service that nee
by manoj.rawat -
Android O Released with Top 7 New Features for App Developers
Android was founded by Andy Rubin, Rich Miner, Nic
by sudhanshu.tripathi -
Top 5 Features That Make Laravel the Best PHP Framework for Development
Laravel is a free open source Web Framework of PHP
by abhishek.tiwari.458 -
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi
Tags
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...