Find difference in two dates in iOS2019 Community Moderator ElectionGetting the difference between two NSDates in (months/days/hours/minutes/seconds)What's the difference between the atomic and nonatomic attributes?NSDate beginning of day and end of dayGet the difference between dates like Facebook comments on iOSSwift Beta performance: sorting arraysNSDate: Extract Date ONLYHow do I make an attributed string using Swift?Getting the difference between two NSDates in (months/days/hours/minutes/seconds)Swift date formatting, getting the date back from server is not the same as sent to the serverFinding the difference between two dates always prints 10Get difference between two dates

Why is there an extra space when I type "ls" in the Desktop directory?

Vocabulary for giving just numbers, not a full answer

Virginia employer terminated employee and wants signing bonus returned

Rationale to prefer local variables over instance variables?

Do I really need to have a scientific explanation for my premise?

Gaining more land

School performs periodic password audits. Is my password compromised?

What is the population of Romulus in the TNG era?

Why restrict private health insurance?

The meaning of ‘otherwise’

What is the generally accepted pronunciation of “topoi”?

Can I negotiate a patent idea for a raise, under French law?

Making a kiddush for a girl that has hard time finding shidduch

When Schnorr signatures are part of Bitcoin will it be possible validate each block with only one signature validation?

Is this Paypal Github SDK reference really a dangerous site?

Why do we say ‘pairwise disjoint’, rather than ‘disjoint’?

Does Christianity allow for believing on someone else's behalf?

Can we track matter through time by looking at different depths in space?

Power Strip for Europe

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

I can't die. Who am I?

What is better: yes / no radio, or simple checkbox?

Possible to detect presence of nuclear bomb?

Signed and unsigned numbers



Find difference in two dates in iOS



2019 Community Moderator ElectionGetting the difference between two NSDates in (months/days/hours/minutes/seconds)What's the difference between the atomic and nonatomic attributes?NSDate beginning of day and end of dayGet the difference between dates like Facebook comments on iOSSwift Beta performance: sorting arraysNSDate: Extract Date ONLYHow do I make an attributed string using Swift?Getting the difference between two NSDates in (months/days/hours/minutes/seconds)Swift date formatting, getting the date back from server is not the same as sent to the serverFinding the difference between two dates always prints 10Get difference between two dates










0















I am not sure what I am doing wrong, I need to find difference between two dates and extract seconds from it, below is my code. I am not getting correct seconds. There is difference of seconds.



 public func captureStartTime() 
captureStartDateTime = Date()


public func captureEndTime(eventType: String, eventElement: String)
let difference = Date().timeIntervalSince(captureStartDateTime)
let interval = Int(difference)
let seconds = interval % 60
let secondsDescrp = String(format: "%02d", seconds)










share|improve this question



















  • 2





    Possible duplicate of Getting the difference between two NSDates in (months/days/hours/minutes/seconds)

    – Rocky
    Mar 6 at 4:43






  • 1





    Date.timeIntervalSince(_:) will give you the interval in seconds. By the % 60 operation, are you trying to convert this to minutes and seconds?

    – Chris Shaw
    Mar 6 at 4:43











  • As your code stands difference is the number of seconds between now and captureStartDateTime

    – MadProgrammer
    Mar 6 at 4:43















0















I am not sure what I am doing wrong, I need to find difference between two dates and extract seconds from it, below is my code. I am not getting correct seconds. There is difference of seconds.



 public func captureStartTime() 
captureStartDateTime = Date()


public func captureEndTime(eventType: String, eventElement: String)
let difference = Date().timeIntervalSince(captureStartDateTime)
let interval = Int(difference)
let seconds = interval % 60
let secondsDescrp = String(format: "%02d", seconds)










share|improve this question



















  • 2





    Possible duplicate of Getting the difference between two NSDates in (months/days/hours/minutes/seconds)

    – Rocky
    Mar 6 at 4:43






  • 1





    Date.timeIntervalSince(_:) will give you the interval in seconds. By the % 60 operation, are you trying to convert this to minutes and seconds?

    – Chris Shaw
    Mar 6 at 4:43











  • As your code stands difference is the number of seconds between now and captureStartDateTime

    – MadProgrammer
    Mar 6 at 4:43













0












0








0








I am not sure what I am doing wrong, I need to find difference between two dates and extract seconds from it, below is my code. I am not getting correct seconds. There is difference of seconds.



 public func captureStartTime() 
captureStartDateTime = Date()


public func captureEndTime(eventType: String, eventElement: String)
let difference = Date().timeIntervalSince(captureStartDateTime)
let interval = Int(difference)
let seconds = interval % 60
let secondsDescrp = String(format: "%02d", seconds)










share|improve this question
















I am not sure what I am doing wrong, I need to find difference between two dates and extract seconds from it, below is my code. I am not getting correct seconds. There is difference of seconds.



 public func captureStartTime() 
captureStartDateTime = Date()


public func captureEndTime(eventType: String, eventElement: String)
let difference = Date().timeIntervalSince(captureStartDateTime)
let interval = Int(difference)
let seconds = interval % 60
let secondsDescrp = String(format: "%02d", seconds)







ios swift nsdateformatter nsdatecomponents nsdatecomponentsformatter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 4:45









iOS Team

1,1401319




1,1401319










asked Mar 6 at 4:39









KashifKashif

53621235




53621235







  • 2





    Possible duplicate of Getting the difference between two NSDates in (months/days/hours/minutes/seconds)

    – Rocky
    Mar 6 at 4:43






  • 1





    Date.timeIntervalSince(_:) will give you the interval in seconds. By the % 60 operation, are you trying to convert this to minutes and seconds?

    – Chris Shaw
    Mar 6 at 4:43











  • As your code stands difference is the number of seconds between now and captureStartDateTime

    – MadProgrammer
    Mar 6 at 4:43












  • 2





    Possible duplicate of Getting the difference between two NSDates in (months/days/hours/minutes/seconds)

    – Rocky
    Mar 6 at 4:43






  • 1





    Date.timeIntervalSince(_:) will give you the interval in seconds. By the % 60 operation, are you trying to convert this to minutes and seconds?

    – Chris Shaw
    Mar 6 at 4:43











  • As your code stands difference is the number of seconds between now and captureStartDateTime

    – MadProgrammer
    Mar 6 at 4:43







2




2





Possible duplicate of Getting the difference between two NSDates in (months/days/hours/minutes/seconds)

– Rocky
Mar 6 at 4:43





Possible duplicate of Getting the difference between two NSDates in (months/days/hours/minutes/seconds)

– Rocky
Mar 6 at 4:43




1




1





Date.timeIntervalSince(_:) will give you the interval in seconds. By the % 60 operation, are you trying to convert this to minutes and seconds?

– Chris Shaw
Mar 6 at 4:43





Date.timeIntervalSince(_:) will give you the interval in seconds. By the % 60 operation, are you trying to convert this to minutes and seconds?

– Chris Shaw
Mar 6 at 4:43













As your code stands difference is the number of seconds between now and captureStartDateTime

– MadProgrammer
Mar 6 at 4:43





As your code stands difference is the number of seconds between now and captureStartDateTime

– MadProgrammer
Mar 6 at 4:43












4 Answers
4






active

oldest

votes


















2














interval is the answer you want. That is the total number of seconds between the two dates.



Your seconds value would only be useful if you wanted to calculate the number of hours, minutes, and seconds or the number of minutes and seconds from the total number of seconds.






share|improve this answer

























  • Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

    – Kashif
    Mar 6 at 4:55











  • You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

    – rmaddy
    Mar 6 at 4:56











  • I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

    – Kashif
    Mar 6 at 5:02


















1














you can also use default date components and according to that compare your dates and you can get the difference in year, month, day etc



let dateString1 = "2019-03-07T14:20:20.000Z"

let dateString2 = "2019-03-07T14:20:40.000Z"



//set date formate

let Dateformatter = DateFormatter()

Dateformatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"



//convert string to date

let dateold = Dateformatter.date(from: dateString1)!

let datenew = Dateformatter.date(from: dateString2)!



//use default datecomponents with two dates

let calendar1 = Calendar.current

let components = calendar1.dateComponents([.year,.month,.day,.hour,.minute,.second], from: dateold, to: datenew)



let seconds = components.second

print("Seconds: (seconds)")





share|improve this answer








New contributor




Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0














    Use the following code to get the difference between two dates, Store current time in startTime when pressed button 1 and store current date time in endTime when pressed button 2, See this code, I hope this helps you.



    var startTime:Date!
    var endTime:Date!

    @IBAction func buttonStartTime(_ sender: UIButton)
    startTime = Date()



    @IBAction func buttonEndTime(_ sender: UIButton)
    endTime = Date()

    let formatter = DateComponentsFormatter()
    formatter.allowedUnits = [.second]
    formatter.unitsStyle = .full
    let difference = formatter.string(from: startTime, to: endTime)!
    print(difference)//output "8 seconds"



    Output




    8 seconds







    share|improve this answer






























      -1














      let startDate = NSDate()
      let endDate = NSDate()
      let calendar = NSCalendar.currentCalendar()
      let dateComponents = calendar.components(NSCalendarUnit.CalendarUnitSecond, fromDate: startDate, toDate: endDate, options: nil)
      let seconds = dateComponents.second
      println("Seconds: (seconds)")





      share|improve this answer








      New contributor




      yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55015683%2ffind-difference-in-two-dates-in-ios%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        2














        interval is the answer you want. That is the total number of seconds between the two dates.



        Your seconds value would only be useful if you wanted to calculate the number of hours, minutes, and seconds or the number of minutes and seconds from the total number of seconds.






        share|improve this answer

























        • Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

          – Kashif
          Mar 6 at 4:55











        • You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

          – rmaddy
          Mar 6 at 4:56











        • I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

          – Kashif
          Mar 6 at 5:02















        2














        interval is the answer you want. That is the total number of seconds between the two dates.



        Your seconds value would only be useful if you wanted to calculate the number of hours, minutes, and seconds or the number of minutes and seconds from the total number of seconds.






        share|improve this answer

























        • Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

          – Kashif
          Mar 6 at 4:55











        • You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

          – rmaddy
          Mar 6 at 4:56











        • I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

          – Kashif
          Mar 6 at 5:02













        2












        2








        2







        interval is the answer you want. That is the total number of seconds between the two dates.



        Your seconds value would only be useful if you wanted to calculate the number of hours, minutes, and seconds or the number of minutes and seconds from the total number of seconds.






        share|improve this answer















        interval is the answer you want. That is the total number of seconds between the two dates.



        Your seconds value would only be useful if you wanted to calculate the number of hours, minutes, and seconds or the number of minutes and seconds from the total number of seconds.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 6 at 4:49

























        answered Mar 6 at 4:43









        rmaddyrmaddy

        244k27323384




        244k27323384












        • Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

          – Kashif
          Mar 6 at 4:55











        • You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

          – rmaddy
          Mar 6 at 4:56











        • I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

          – Kashif
          Mar 6 at 5:02

















        • Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

          – Kashif
          Mar 6 at 4:55











        • You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

          – rmaddy
          Mar 6 at 4:56











        • I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

          – Kashif
          Mar 6 at 5:02
















        Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

        – Kashif
        Mar 6 at 4:55





        Thanks for sharing, however still interval is not giving exact second values. There is difference if 10 - 15 seconds between previous and current date. I have also used NSCalendar still its not giving accurate one.

        – Kashif
        Mar 6 at 4:55













        You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

        – rmaddy
        Mar 6 at 4:56





        You need to update your question with more specific details. Show the exact values being used and your actual and expected results.

        – rmaddy
        Mar 6 at 4:56













        I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

        – Kashif
        Mar 6 at 5:02





        I need to get seconds between two button clicks, so on one button click, i have retrieved date as captureStartDateTime, on second button click i retrieved current date and time and try to find seconds in interval.

        – Kashif
        Mar 6 at 5:02













        1














        you can also use default date components and according to that compare your dates and you can get the difference in year, month, day etc



        let dateString1 = "2019-03-07T14:20:20.000Z"

        let dateString2 = "2019-03-07T14:20:40.000Z"



        //set date formate

        let Dateformatter = DateFormatter()

        Dateformatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"



        //convert string to date

        let dateold = Dateformatter.date(from: dateString1)!

        let datenew = Dateformatter.date(from: dateString2)!



        //use default datecomponents with two dates

        let calendar1 = Calendar.current

        let components = calendar1.dateComponents([.year,.month,.day,.hour,.minute,.second], from: dateold, to: datenew)



        let seconds = components.second

        print("Seconds: (seconds)")





        share|improve this answer








        New contributor




        Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.
























          1














          you can also use default date components and according to that compare your dates and you can get the difference in year, month, day etc



          let dateString1 = "2019-03-07T14:20:20.000Z"

          let dateString2 = "2019-03-07T14:20:40.000Z"



          //set date formate

          let Dateformatter = DateFormatter()

          Dateformatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"



          //convert string to date

          let dateold = Dateformatter.date(from: dateString1)!

          let datenew = Dateformatter.date(from: dateString2)!



          //use default datecomponents with two dates

          let calendar1 = Calendar.current

          let components = calendar1.dateComponents([.year,.month,.day,.hour,.minute,.second], from: dateold, to: datenew)



          let seconds = components.second

          print("Seconds: (seconds)")





          share|improve this answer








          New contributor




          Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






















            1












            1








            1







            you can also use default date components and according to that compare your dates and you can get the difference in year, month, day etc



            let dateString1 = "2019-03-07T14:20:20.000Z"

            let dateString2 = "2019-03-07T14:20:40.000Z"



            //set date formate

            let Dateformatter = DateFormatter()

            Dateformatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"



            //convert string to date

            let dateold = Dateformatter.date(from: dateString1)!

            let datenew = Dateformatter.date(from: dateString2)!



            //use default datecomponents with two dates

            let calendar1 = Calendar.current

            let components = calendar1.dateComponents([.year,.month,.day,.hour,.minute,.second], from: dateold, to: datenew)



            let seconds = components.second

            print("Seconds: (seconds)")





            share|improve this answer








            New contributor




            Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.










            you can also use default date components and according to that compare your dates and you can get the difference in year, month, day etc



            let dateString1 = "2019-03-07T14:20:20.000Z"

            let dateString2 = "2019-03-07T14:20:40.000Z"



            //set date formate

            let Dateformatter = DateFormatter()

            Dateformatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"



            //convert string to date

            let dateold = Dateformatter.date(from: dateString1)!

            let datenew = Dateformatter.date(from: dateString2)!



            //use default datecomponents with two dates

            let calendar1 = Calendar.current

            let components = calendar1.dateComponents([.year,.month,.day,.hour,.minute,.second], from: dateold, to: datenew)



            let seconds = components.second

            print("Seconds: (seconds)")






            share|improve this answer








            New contributor




            Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer






            New contributor




            Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered Mar 7 at 4:57









            Kaushik KapadiyaKaushik Kapadiya

            111




            111




            New contributor




            Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            Kaushik Kapadiya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















                0














                Use the following code to get the difference between two dates, Store current time in startTime when pressed button 1 and store current date time in endTime when pressed button 2, See this code, I hope this helps you.



                var startTime:Date!
                var endTime:Date!

                @IBAction func buttonStartTime(_ sender: UIButton)
                startTime = Date()



                @IBAction func buttonEndTime(_ sender: UIButton)
                endTime = Date()

                let formatter = DateComponentsFormatter()
                formatter.allowedUnits = [.second]
                formatter.unitsStyle = .full
                let difference = formatter.string(from: startTime, to: endTime)!
                print(difference)//output "8 seconds"



                Output




                8 seconds







                share|improve this answer



























                  0














                  Use the following code to get the difference between two dates, Store current time in startTime when pressed button 1 and store current date time in endTime when pressed button 2, See this code, I hope this helps you.



                  var startTime:Date!
                  var endTime:Date!

                  @IBAction func buttonStartTime(_ sender: UIButton)
                  startTime = Date()



                  @IBAction func buttonEndTime(_ sender: UIButton)
                  endTime = Date()

                  let formatter = DateComponentsFormatter()
                  formatter.allowedUnits = [.second]
                  formatter.unitsStyle = .full
                  let difference = formatter.string(from: startTime, to: endTime)!
                  print(difference)//output "8 seconds"



                  Output




                  8 seconds







                  share|improve this answer

























                    0












                    0








                    0







                    Use the following code to get the difference between two dates, Store current time in startTime when pressed button 1 and store current date time in endTime when pressed button 2, See this code, I hope this helps you.



                    var startTime:Date!
                    var endTime:Date!

                    @IBAction func buttonStartTime(_ sender: UIButton)
                    startTime = Date()



                    @IBAction func buttonEndTime(_ sender: UIButton)
                    endTime = Date()

                    let formatter = DateComponentsFormatter()
                    formatter.allowedUnits = [.second]
                    formatter.unitsStyle = .full
                    let difference = formatter.string(from: startTime, to: endTime)!
                    print(difference)//output "8 seconds"



                    Output




                    8 seconds







                    share|improve this answer













                    Use the following code to get the difference between two dates, Store current time in startTime when pressed button 1 and store current date time in endTime when pressed button 2, See this code, I hope this helps you.



                    var startTime:Date!
                    var endTime:Date!

                    @IBAction func buttonStartTime(_ sender: UIButton)
                    startTime = Date()



                    @IBAction func buttonEndTime(_ sender: UIButton)
                    endTime = Date()

                    let formatter = DateComponentsFormatter()
                    formatter.allowedUnits = [.second]
                    formatter.unitsStyle = .full
                    let difference = formatter.string(from: startTime, to: endTime)!
                    print(difference)//output "8 seconds"



                    Output




                    8 seconds








                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 6 at 6:33









                    AtulParmarAtulParmar

                    1,108521




                    1,108521





















                        -1














                        let startDate = NSDate()
                        let endDate = NSDate()
                        let calendar = NSCalendar.currentCalendar()
                        let dateComponents = calendar.components(NSCalendarUnit.CalendarUnitSecond, fromDate: startDate, toDate: endDate, options: nil)
                        let seconds = dateComponents.second
                        println("Seconds: (seconds)")





                        share|improve this answer








                        New contributor




                        yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.
























                          -1














                          let startDate = NSDate()
                          let endDate = NSDate()
                          let calendar = NSCalendar.currentCalendar()
                          let dateComponents = calendar.components(NSCalendarUnit.CalendarUnitSecond, fromDate: startDate, toDate: endDate, options: nil)
                          let seconds = dateComponents.second
                          println("Seconds: (seconds)")





                          share|improve this answer








                          New contributor




                          yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






















                            -1












                            -1








                            -1







                            let startDate = NSDate()
                            let endDate = NSDate()
                            let calendar = NSCalendar.currentCalendar()
                            let dateComponents = calendar.components(NSCalendarUnit.CalendarUnitSecond, fromDate: startDate, toDate: endDate, options: nil)
                            let seconds = dateComponents.second
                            println("Seconds: (seconds)")





                            share|improve this answer








                            New contributor




                            yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.










                            let startDate = NSDate()
                            let endDate = NSDate()
                            let calendar = NSCalendar.currentCalendar()
                            let dateComponents = calendar.components(NSCalendarUnit.CalendarUnitSecond, fromDate: startDate, toDate: endDate, options: nil)
                            let seconds = dateComponents.second
                            println("Seconds: (seconds)")






                            share|improve this answer








                            New contributor




                            yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered Mar 6 at 5:52









                            yaswardhanyaswardhan

                            12




                            12




                            New contributor




                            yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            yaswardhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55015683%2ffind-difference-in-two-dates-in-ios%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                                Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                                2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived