Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

4
Help subtracting two calendar dates as Strings.
Post Flair (click to view more posts with a particular flair)
Post Body

I am attempting to create a countdown between two days. For example an object was created on 05-12-2022 ( "dd/MM/yyyy" format)

I want this to live up until 12-12-2022 (a week later). How would you recommend I go about grabbing the number of days between each and starting a countdown of sorts (ie. 3 days left, 2 days left, etc).

This is how I'm grabbing the two dates currently, just don't know how to subtract them.

func removeEntryDate() -> String{
        let nowDate = Date()
        let endDate = Calendar.current.date(byAdding: .day, value:  7, to: Date())
        var dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "dd/MM/yyyy"
       //return when we should delete past journal entry
        var dateString = dateFormatter.string(from: endDate! as Date)
        print(dateString)
        return dateString
    }

    func currentDate() -> String {
        let date = NSDate()
        var dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "dd/MM/yyyy"
        var dateString = dateFormatter.string(from: date as Date)
       //return when we should delete past journal entry
        return dateString
    }

Author
Account Strength
90%
Account Age
9 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,139
Link Karma
597
Comment Karma
542
Profile updated: 6 days ago
Posts updated: 1 month ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago