Results 1 to 5 of 5

Thread: calculating dates in PHP

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default calculating dates in PHP

    how i can calculates dates n ages in PHP

    my all dates are stores in database as unix timestamp..


    is there any predefined functions which can b used to calculate dates ? i.e.
    i did some activity on 12-01-10 and on 12-02-10 it l show me that 1 month gone for this activity etc?


    thanks in advanced...

  2. #2
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    ? post soon plz

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    http://www.php.net/manual/en/function.strtotime.php
    http://www.php.net/manual/en/function.date.php

    Input a formatted date(s) and convert to a timestamp using strtotime() or a similar function.
    Then do math on the date(s) and use date() to format as needed.

    There is no "default" way to do this, but depending on your needs, you can put together a combination of a few functions to accomplish any necessary math.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    wel thanks...

    i already done like this.. but i was looking for some better methods...\

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The only better method would be to write a function for yourself that automates the process, using those functions as the base.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •