4,831 questions
-1
votes
1
answer
70
views
NSDateFormatter returns nil for date string from server
I received a date string and a timezone from a web service and I am needing to convert into an NSDate. When setting the format and timezone, I get nil:
NSString *timeZoneString = @"Europe/Paris&...
3
votes
3
answers
385
views
Setting seconds to 0 is also adding 1 to minutes in Swift
I'm trying to set the seconds of a date object to 0 with the following:
if let date = value{
var calendar = Calendar.current
if let mdate = calendar.date(bySetting: .second, value: 0, of: date) ...
0
votes
3
answers
190
views
Convert HH:mm string to GMT time string HH:mm
I'm using this code to convert HH:mm string to GMT time string HH:mm:
func convertToGMT(timeString: String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "...
-1
votes
1
answer
192
views
Using DateFormatter for shortening the date (UNIX timestamp)
I am trying to solve my issue with a Unix Timestamp. I figured out how to present it but the result is too long - it says:
"Friday March 31, 2023 at 11:13:52 PM Central European Summer Time"
...
1
vote
0
answers
1k
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
...
1
vote
1
answer
48
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];
[...
0
votes
0
answers
17
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....
0
votes
0
answers
760
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 ...
-1
votes
2
answers
2k
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(...
0
votes
1
answer
59
views
NSString to NSDate and back again to NSString
I have a date string in this format: 2022-09-07T11:11:16+0300 and I want to convert it to NSDate and back again to NSString, I use this code:
NSString * dateCreatedString = @"2022-09-07T11:11:16+...
1
vote
1
answer
2k
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.
...
-1
votes
2
answers
102
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 ...
0
votes
1
answer
89
views
How to get date matching a particular time in a given time zone - Swift
How can I get a Date object that matches a given time in a given time zone?
For example, I want to get the Date that represents the next 3AM CST.
I thought of this, but I'm not sure if it's the best ...
0
votes
1
answer
235
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: ...
1
vote
1
answer
607
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))...