Questions tagged [nsdateformatter]

Class that creates string representations of NSDate (and NSCalendarDate) objects, and convert textual representations of dates and times into NSDate objects.

Filter by
Sorted by
Tagged with
0 votes
2 answers
35 views

Reload SwiftUI view when DateFormatter format updates?

Related to forcing an update, I would like SwiftUI to reload and update my content view when a DateFormatter instance's format property changes. Example: private extension String { enum ...
Ilias Karim's user avatar
  • 4,935
0 votes
0 answers
14 views

Android app Matter integration - not able to connect the device

I am trying to run the google sample POC for the matter with the module ESP32, sharing the url link which I am referring to is here. But I am not able to stablish the connection, intermittent call ...
Virendra Pal Singh's user avatar
0 votes
0 answers
34 views

Mock simulator / device time format setting

There was a bug within our app where if the user set their time format in settings to the 24-Hour Time format, the time would not show up as desired, which is always in the 12 hour format with am/pm. ...
Shawn Frank's user avatar
  • 4,525
0 votes
1 answer
106 views

Convert datetime to string in sql

Using SQL language , trying to pull the same dates as you can see from the code as below; select aa.sim from app_date1 aa left join app_date2 bb on aa....
latife's user avatar
  • 11
0 votes
0 answers
37 views

why this date formatter not working correctly?

facing the following issue: I'm try to create a date by adding 2 strings one with a date "23/06/2023" and one is the time "21:00" why I'm getting this strange result: see my ...
Damiano Miazzi's user avatar
0 votes
0 answers
509 views

Capture of 'dateFormatter' with non-sendable type 'ISO8601DateFormatter' in a `@Sendable` closure

I have the following code let dateFormatter = ISO8601DateFormatter() dateFormatter.formatOptions.insert(.withFractionalSeconds) decoder.dateDecodingStrategy = .custom({ decoder in ...
erotsppa's user avatar
  • 14.5k
1 vote
1 answer
33 views

Converting NSString into NSDate in objective c for mention Date String

I am trying to convert DateString into Different DateFromat. strDate = @"24-08-2022 06:38:50 +0:00" NSDateFormatter *dateformate = [[NSDateFormatter alloc] init]; [...
Parth's user avatar
  • 19
0 votes
1 answer
67 views

Convert Int to date formatter followed with timezone

Trying to convert Int to formatted string date with supplied timezone value and formatter to expected result "12/01/2022 09:03:41 PM THA". //Response Data. { "code": "...
kiran's user avatar
  • 4,325
0 votes
0 answers
24 views

Swift - Problem converting year + weekOfYear components to Date [duplicate]

let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yy/MM/dd" let d = dateFormatter.date(from: "2022/12/15")! // First block (as expected) let compsYearMonth = ...
Jan Doekt's user avatar
1 vote
1 answer
44 views

Getting difference between two dates like in facebook, instagram comment section

I am working on an app in which i have to display the date/time difference between current date and posted date in format like "1 hour ago", "4 days ago" I got api response in this ...
Abhinandan Pratap's user avatar
0 votes
1 answer
88 views

Convert Int To Date Formatter value

Below code I used to convert Int to Time. //MARK: - Convert Date To String func dateToString(date: Date, dateFormat: String) -> String { let dateFormater = DateFormatter() dateFormater....
kiran's user avatar
  • 4,325
0 votes
1 answer
85 views

How to convert a date to a specific timezone when user is in a different timezone?

I have a problem in handling dates in Swift in different timezones. I'm getting an Italian date from my server and I'm trying to convert it into a Date through the following function: func ...
Rexam's user avatar
  • 843
0 votes
0 answers
16 views

Swift String to Date conversion from youtube API publishedAt [duplicate]

I need to convert this date string to a date object. This is the format that youtube API sends for a published at date. 2022-10-26T02:40:04.645878Z let all_time_date = "2022-10-26T02:40:04....
husharoonie's user avatar
0 votes
1 answer
36 views

How to get the date with specific hour and minute of today from "HH:mm" string in Objecive-C

I have a time string like "HH:mm" format and I want to get a NSDate object of today at that time. I am using NSDateFormatter but it not work. Here is my code: NSString *dateString = @"...
BigLiao's user avatar
  • 539
0 votes
0 answers
265 views

iOS Swift app - 24 hour format from Settings app is not respected for Germany and France

I have to display date and time in an iOS app based on locale (Region) and time format (24-Hour vs 12-Hour) set in the device Settings app. I am using below code for the same :- class func ...
letsbondiway's user avatar
0 votes
1 answer
89 views

Converting Python time.asctime() to Swift Date using DateFormatter

I am working with a series of string representations of timestamps returned by time.asctime() in Python. The documentation states: Convert a tuple or struct_time representing a time as returned by ...
John Harrington's user avatar
0 votes
0 answers
55 views

Swift Convert String to Date

I have a string with time in it "20:52" and I am trying to use DateFormatter to convert it to Date. My code is: let dateFormatter = DateFormatter() dateFormatter.locale = Locale.current ...
ez4nick's user avatar
  • 9,777
0 votes
0 answers
196 views

iOS: 24 hour time formatting not honored with Region=Canada, Language=French

If Language is French and Region is Canada, the Languge & Region pane in Settings shows 24 hour time formatting in the sample area as expected, as does the rest of iOS and stock apps. But if I ...
t9mike's user avatar
  • 1,546
1 vote
0 answers
371 views

iOS: Date formatter with "ar_AE" language code not converting date to Arabic

When I try to convert date to Arabic language with below code & ar_AE language code, it shows date in western numerals not in Arabic. let dateFormatter = DateFormatter() dateFormatter.dateStyle = ...
Nico's user avatar
  • 1,798
0 votes
1 answer
52 views

IOS ObjC NSDateFormatter stringFromDate returns nil

I have a function that takes 2 parameters, a date string in format @"2022-09-19T18:00:00.000Z", and a pattern (date format): @"MMM d". The problem is that the date is always nil, ...
Mod3rnx's user avatar
  • 860
-2 votes
2 answers
806 views

Swift: Converting string to date [duplicate]

I have a date as String but I want to convert it to Date. The date in string looks like this - "2022-09-09T07:00:00.0000000". Code to convert it to Date: public static func dateStringToDate(...
tech_human's user avatar
  • 6,684
0 votes
0 answers
83 views

datefromstring always return nil on physical device objective c

I have to show app build date in the project. In "dd MMM yyyy" format. GetBuildDate { NSString *buildDate; // Get build date and time, format to 'yyMMddHHmm' NSString *dateStr = ...
Ruhi's user avatar
  • 176
1 vote
1 answer
61 views

DateTime2 formart conversion to Swift Date

I have a date string coming from back-end as "2022-08-16T13:44:11.8743234". Date formatting and conversion is the oldest skill in the book but I cannot figure out why I'm unable to convert ...
pnizzle's user avatar
  • 6,253
-3 votes
1 answer
43 views

iOS-Swift How to convert a String of Date to another String of Date [closed]

I have this String "Aug 15, 2022". How can I convert it to "Monday, August 15, 2022"
Alex171's user avatar
  • 37
1 vote
1 answer
790 views

DateFormatter returns previous day

I've looked around and people have had problems with different years, random and changing results, and nil dates, but nothing like what I have, so I am asking here. Note I am in Playground right now. ...
Ben A.'s user avatar
  • 1,088
0 votes
0 answers
205 views

Wrong date in client ios device in Thailand different from my device in India

I am receiving the date as a string from the server via rest API and changing the format of that string. For this, I am converting string to date and then converting date back to string back to date ...
Anuj Kumar's user avatar
-1 votes
2 answers
75 views

Swift - iOS Unable to convert to required date format

I am using date picker in my application. After selects particular date, It's not able to converting to required format. Datepicker date: 2021-07-21 13:53:38 +0000 expected format 21 July 2021 I ...
Anilkumar iOS - ReactNative's user avatar
0 votes
2 answers
105 views

How can I convert date string to time string?

I have a string that looks like this: "date": "2022-06-30T02:15:00.000+07:00" And I formatted it to convert to "HH:mm" like this: func formatTime(string: String) -> ...
Dagg Tuan's user avatar
  • 113
-1 votes
3 answers
94 views

DateFormatter showing incorrect time

My requirement is to convert date string (in PHT) received from my API to another date string format. API Date String format: "MM/dd/yyyy HH:mma" eg. "06/28/2022 06:55PM" UI Date ...
Vaibhav Misra's user avatar
1 vote
1 answer
437 views

Swift date formatter off by one day [duplicate]

It's pretty bizarre. If I look at the Data object it correctly has 01/01/1990, but when converting it to a string it returns 12/31/1989. This seems to have only recently started happening as the code ...
StainlessSteelRat's user avatar
0 votes
1 answer
170 views

DateComponentsFormatter - same dates, different results

Why is dateRemainingText2 giving different result from dateRemainingText? Obviously dateRemainingText2 is wrong. Here's my code: import Foundation let startDate = Calendar.current.date(from: ...
user14119170's user avatar
  • 1,301
1 vote
1 answer
278 views

Can I make RelativeDateTimeFormatter display more units such year, month and day?

Here's my code: let startDate = Calendar.current.date(from: DateComponents(year: 2022, month: 5, day: 1)) ?? .now let endDate = Calendar.current.date(from: DateComponents(year: 2020, month: 6, day: 2))...
user14119170's user avatar
  • 1,301
1 vote
1 answer
33 views

ios NSDateFormatter transform date result error

my code is as fllow: NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; fmt.dateFormat = "yyyy-MM-dd"; fmt.timeZone = NSTimeZone.systemTimeZone; NSString *selfStr = [fmt ...
leosun's user avatar
  • 39
0 votes
1 answer
450 views

Applying timezone offset data provided by OpenWeatherMap (Swift)

Getting the current day, hour, minute etc for the users current location is fairly straight forward using a function like this, so long as you have UTC data: func getHourForDate(_ date: Date?)-> ...
jmsapps's user avatar
  • 408
0 votes
0 answers
45 views

Fireebase Crashlitics -[NSDateFormatter _setDateFormat:alreadyLocked:]

I get -[NSDateFormatter _setDateFormat:alreadyLocked:] in my Firebase Crashlytics, How it caused and how to fix it? Is it a thread-safety issue?
Tal Spektor's user avatar
1 vote
1 answer
256 views

Properly ordering month and date according to locale

I want to display start and end date of week in a human readable format. Using MMMM d as date format base. For example: - March 7 - 13 - February 28 - March 6 - 7-13 de marzo So if week start and end ...
sha's user avatar
  • 17.8k
1 vote
2 answers
5k views

Timezone in swift [duplicate]

I am struggling quite a bit with dates. I have the following code: Current Date in Amsterdam: 22-Februari-2022 - 11:40 Current Date in New York: 22-Februari-2022 - 05:40 The dateBoughtString goes in ...
Mr_Bull3t's user avatar
0 votes
1 answer
69 views

Date Formatter unexpected output

let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "en_US_POSIX") dateFormatter.dateFormat = "MMMM dd, yyyy 'at' HH:mm:ss aa z" dateFormatter.amSymbol = &...
Selçuk Yıldız's user avatar
0 votes
2 answers
114 views

how to get time difference form formatted time string values

Hi how to get time difference for two sting value startTime = "09:00 AM" EndTime = "05:30 PM" func timeDifferenceBetweenTwoTime(startTime: String, endTime:String) ->CGFloat{ ...
kiran's user avatar
  • 4,325
-3 votes
1 answer
299 views

How to convert 10digit int to date [closed]

How to convert 1640704675 into date. extension Date { var millisecondsSince1970:Int64 { return Int64((self.timeIntervalSince1970 * 1000.0).rounded()) } init(milliseconds:Int64) { ...
kiran's user avatar
  • 4,325
-4 votes
1 answer
461 views

Formatting a Date and Time in Swift [closed]

I have this time format 2022-01-09T19:04:16 obtained from an API. I would like to show a readable time from this string and also, possibly the difference from given time and current time. I cannot ...
heavyguidence's user avatar
0 votes
1 answer
164 views

Issue Decoding Child Models as Properties with JSONDecoder?

Any clue why my decoding is not working properly? I've created 3 models: Portfolio, Tokens, and Holdings, and for some reason Holdings is causing issues, not sure if it's the structure, but here's the ...
VAlexander's user avatar
0 votes
0 answers
19 views

NSDateFormatter.dateFromString returns nil when changing phone settings [duplicate]

I am trying to convert a string into Date in iOS (Swift/Objective C) but I have an issue when the date contains the hours in 24 formats like 2018-11-24_18-11-10 The issue is that when the phone uses ...
Mahmoud Adam's user avatar
  • 5,802
0 votes
0 answers
266 views

NSDateFormatter dateFromString crash (in call from formatter.date(from: String)

I'm getting a crash reported on my call to date(from:) on my formatter: guard let date = DateFormatter.longYearFormatter(timeZone: timeZone).date(from: dateString) else { return } dateString here is ...
Logan's user avatar
  • 1,202
-2 votes
1 answer
327 views

Swift date formatter wrongfully converting/creating dates/strings [duplicate]

Greetings there m'ladies, m'lords! Long story short I have a helper struct where I have some helper functions for creating date formatters, Date objects and String representations of dates. I've ...
Sorin Miroiu's user avatar
0 votes
1 answer
107 views

Parsing Date JSON Crash in UK region

I am downloading json with a date string. An example is "2020-06-08T09:48:47.570" I am easily able to convert this string into a date with a DateFormatter and a dateFormat of "yyyy-MM-...
Nate Mann's user avatar
  • 675
1 vote
2 answers
204 views

How to know Date format getting from sever [duplicate]

I am trying to get date format of a date that I am getting from server. What will be the format of this date: 2021-10-14T17:53:03.753588+05:30 What I tried: yyyy-MM-dd'T'HH:mm:ssXXX But Its not ...
QM Dev's user avatar
  • 33
0 votes
1 answer
240 views

Issue with determining if time format is 12 hours or 24 hours

In my AppDelegate's applicationWillEnterForeground(_), I have the below code to determine if the device is set to 12 hour or 24 hour time format. func applicationWillEnterForeground(_ application: ...
tech_human's user avatar
  • 6,684
0 votes
1 answer
80 views

DateFormatter does NOT convert specific dates (Swift)

I have the below code on playground and app and DateFormatter are returning nil just for the date "1990-10-21": let dateFormatter = DateFormatter() dateFormatter.dateFormat = "YYYY-MM-...
Aisenhein's user avatar
-3 votes
1 answer
92 views

How to convert date from dd/MM to dd/MM/yyyy? [duplicate]

I have to change the format of the date from dd/MM to dd/MM/yyyy and I use this code let dateFormatter = DateFormatter() dateFormatter.dateFormat = "dd/MM" let date = dateFormatter.date(from:...
Alexandra's user avatar

1
2 3 4 5
59