SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date difference doubt...

    hello can any body tell how to find the difference between two date like the date is like 2009-01-03 and the other date is 2009-01-05 i need to get the difference this two like the answer as 2 how and if the leap year comes also it should verify in the proper format.... pls can any body help

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Are the dates coming from a database? If so do you want that difference in days to be worked out in the database?

    Do both of your sample dates you quoted come from Jan 2009? (could the latter possibly mean 1st of May 2009?)

  3. #3
    SitePoint Enthusiast premiumscripts's Avatar
    Join Date
    Aug 2009
    Location
    PremiumScripts.com
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've already asked this in another thread and I already told you how to do it.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    at least he spelled "doubt" correctly
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    With PHP 5.3, you could do...
    PHP Code:
    <?php
    $oDate 
    = new DateTime('28-02-2000');
    printf(
        
    '%s day(s) difference.',
        
    $oDate->diff(new DateTime('01-03-2000'))->format('%d')
    );
    #2 day(s) difference.
    ?>
    PHP Code:
    <?php
    $oDate 
    = new DateTime('28-02-2001');
    printf(
        
    '%s day(s) difference.',
        
    $oDate->diff(new DateTime('01-03-2001'))->format('%d')
    );
    #1 day(s) difference.
    ?>
    It takes leaps years into account.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hai friends thanks for the reply i have done it in the other way like mktime so i got it now their is one more dought for me pls solve it like i have the link where i have added a reg_key where i need to add one more reg_key1 how like

    www.kuttus.com/edit_hello?reg_key=@2222

    ok with this i need to add the reg_key1 also where i added and tried but i am not getting tht function in the edit_hello so can u show how to add it

  7. #7
    SitePoint Enthusiast premiumscripts's Avatar
    Join Date
    Aug 2009
    Location
    PremiumScripts.com
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    He forgot how to spell "doubt" again

    Anyway, your question doesn't make much sense and your site isn't loading.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •