Questions tagged [relativedatetimeformatter]
4 questions
1
vote
1 answer
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 format
"created_at": "2022-12-03 05:24:00"
and i am using this…

Abhinandan Pratap
- 2,142
- 1
- 18
- 39
1
vote
1 answer
RelativeDateTimeFormatter memory leak
Please I'm using this extension to get the past time from the date.
But I'm seeing memory leak in RelativeDateTimeFormatter()
Any suggestions please?
extension Date {
func timeAgoDisplay() -> String {
let formatter =…

Alama Yasein
- 37
- 5
0
votes
1 answer
Is there a standard to represent relative date codes?
Is there a standard or at least generally accepted convention to represent relative dates?
For ex.,
-5d => 5 days ago
5d 4m 3s => 5 days, 4 minutes and 3 secs
where units are y, M, d, h, m, s
Note that I checked on the question but that talks about…

metasync
- 338
- 1
- 10
0
votes
0 answers
RelativeDateTimeFormatter returns one day less than expected
Why the following code prints me "Tomorrow" and not "In 2 days"?
let dateString = "2022-05-21"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let date = dateFormatter.date(from:…

Giorgio
- 1,973
- 4
- 36
- 51