How to avoid forcing a second component one day?

I'm using this code to create a document for a document base application for macOS, which hase as name the seconds elapsed since the Date() referencing date. func saveDocumentInApplicationSupport() { do { // create a directory in Application Support

Get the number of weeks for a given ISO 8601 calendar year

I need to make a function for calculating the number of weeks of a given year in swift, according to the ISO-week-system (ISO8601). I need the number as an Int. First I figured I need to make a NSDate for december 31st and just ask what week that's i

Swift: format string based on the number of seconds

There is a NSTimer object in my app that counts elapsed time in seconds. I want to format an UILabel in my app's interface in the such way it matches the well know standard. Example 00:01 - one second 01:00 - 60 seconds 01:50:50 - 6650 seconds I wond

How to create NSDate that will be in DST mode

I would like to know how it is possible to create NSDate that will be in DST mode. I am using method nextDaylightSavingTimeTransition This is from documentation: This property contains the date of the next (after the current instant) daylight saving

Nsdate always returns null

As i'm getting response from server look like this-(StartTime = "19/02/2016 13:52") and I want to replace this string with this - (StartTime = "19/02/2016 at 01:52 PM")...I want to append AM/PM at the end and I'm using this code... NSD

Delete and reformat NSDate does not work?

Iam trying to reformat this NSdate (2016-02-11 01:00:00 +0000 ) into this (11-02-2016). I have used below code and its returning null. //newDate format is 2016-02-11 01:00:00 +0000 NSString *dateString = [[self dateFormatter] stringFromDate:newDate];

Swift How to convert Parse created From time to time?

I've retrieved createdAt column from Parse and i wrote it on UITableview for each row, but the time and date looks like this on tableview : 23-12-2015 01:04:56.380 28-08-2015 19:45:09.101 I want to convert that to time ago for example: Today 1:04 PM

How to get how many minutes have passed for some time?

I would like that my app would show how much time has passed since some time mark, like Stopwatch. Should I used NSdate? I've tried using NSDate(timeIntervalSinceReferenceDate:_) and as parameter I wanted to chose NSDate(timeIntervalSince1970: someTi

NSDateFormatter incorrect dateFromString

I am setting the value of a UITableViewCell's detailTextLabel to the current date and am then allowing the user to modify that date using a UIDatePicker. I set the text label like this NSDate *currentDate = [NSDate date]; NSDateFormatter *dateFormatt

NSDate storage in master data (fast)

I'm new to swift and I'm trying to understand parts of it. I've been working on an app where I need to store a date, and I just can't figure it out. Any input would be great. Code to store date var appDel: AppDelegate = (UIApplication.sharedApplicati

NSDateFormatter incorrect date conversion

I am using NSDateFormatter, to convert NSString to NSDate. For e.g if my NSString value is Jun 24,2015 Then it is getting converted as 2015-06-23 18:30:00 +0000, which is incorrect. It should be "24" instead of "23". I am using below c

iOS NSDate () returns an incorrect time

I am trying to get current date in Swift using NSDate(). When I create breakpoint and stop application, I can see that there is 3 hours difference with devices' system time. Application is running on real iPhone. How to fix this? I also wrote the fol

Date of the week of the week that contains the original date

I want the date of Weekday=friday of the week which contain original date I had tried with the below coding but it is not working :- Nsdate currDate;(currDate can be date) int dayofweek; // Detect the day of week NSString *Start_date = @"13/nov/2014&

ios date time in am pm date formatter issue

i am trying to change date string get from data base to date(mm.dd.yy) and time(am pm). this way i am getting date time from sqlite: rs=[db executeQuery:@"select *,strftime('%m.%d.%Y %H:%M',update_date) AS DATETIME from sales_order where deleted=0 an

Could not parse the date of a string

I can't parse date from string via NSDateFormatter. The date string is @"2014-01-21T20:00:36+04:00". I am trying to use this format string: @"yyyy-MM-ddTHH:mm:ss" but it doesn't work. Please help me. The full code is: NSDateFormatter *

NSDate detection with NSDataDetector

I tried to get a NSDate from a NSString with UNKNOWN format, So I wrote a function like below -(void)dateFromString:(NSString*)string { NSError *error = NULL; NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:(NSTextCheckingTypes)NSTex

date returned by the dateFromString method

Please help me solve the problem. (The values for objValidation.aRange.MinimumValue, objValidation.aRange.MaximumValue come from web services) (I am getting wrong dates in firstDate, secondDate.) NSDateFormatter *df = [[NSDateFormatter alloc] init];

Get bad weather using NSDateFormatter

When i am [dateFormatter setDateFormat:@"HH:mm"] using to fetch the current hour i am getting correct time till 12:59 but after that it again starts from 1:00 i.e. 12:59 is displayed as 12:59 but 14:00 is displyed as 2:00. Please let me if anyon

Current day of the year

Possible Duplicate: How do you calculate the day of the year for a specific date in Objective C I am looking for a way to find the day number which has past in current year. For example if today was 2013-03-22 , then the number should be 81, because

IOS Setting Viewcontroller Property Incorrect Access Error

I am trying to set the property of a child view controller (DateViewController) from the parent and getting a bad access error the second time I do so. Here is the code. This is the DateViewController.h. The problem lies with the selectedDate propert

NSDateFormatter does not work with 4:15:00

How do I convert "4:15:00 PM" to an NSDate? Below is the code I have: NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"HH:mm:ss aa"]; NSDate *date = [df dateFromString:@"4:15:00 PM"]; NSLog(@"dat

Convert GMT date format to locale-based format

How can we convert NSDate object in GMT format to the date format with current locale/device settings? For example if a device is in US and in PDT time zone then I want to convert GMT time to its equivalent PDT time.Strictly, you cannot convert an NS

UIDatePicker: time mode: initializes the time (must be simple)

All, This seems like such a simple thing, but I cannot find* the right method to create a UIDatePicker, in time mode, and have it initialized to a specific time. I don't want date -- just time (think alarm clock). I have created a NSDate object: NSDa

The most effective way to implement an alarm on iPhone

I have implemented a simple clock like so: - (void)runTimer { timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showActivity) userInfo:nil repeats:YES]; } - (void)showActivity { NSDateFormatter *df = [[[NSDateFormatte

iPhone - get the number of days between two dates

I'm writing a GTD app for the iPhone. For the due tasks, I want to display something like "Due tomorrow" or "Due yesterday" or "Due July 18th". Obviously, I need to display "Tomorrow" even if the task is less than 2

Formatting an NSDate

I am pulling data from an RSS Feed. One of the keys in the feed is is a string representing the date and time the item was created. I am trying to convert this string value to an NSDate. The string value is returned from the RSS feed as: 2009-11-18T2

How to find which day of the week for a given date using cocoa

I'm trying to figure out what day (i.e. Monday, Friday...) of any given date (i.e. Jun 27th, 2009) Thank you.I've been doing: NSDateFormatter* theDateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [theDateFormatter setFormatterBehavior:NSD