Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: date

  1. #1
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    date

    is it possible to change the date to show 1224 today and start counting ?

    <?php
    $date = new DateTime("2008-03-10");
    $date->modify("-384 Year");
    echo $date->format("Y-m-d");
    ?>


  • #2
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    <?php
    $currentDate = new DateTime('2008-03-10');
    $endDate = new DateTime('1224-03-10');

    while($currentDate < $endDate) {
    echo $currentDate -> format('Y-m-d') . ' till ';
    $currentDate -> modify('+784 Years');
    echo $currentDate -> format('Y-m-d') . ' <br />';
    }
    ?>
    this will work ?

  • #3
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    noone knows ?

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Mihai View Post
    this will work ?
    did you test it?

    - you must close the code between [ php] and [ /php] tags.
    - remove the space before and after, ->
    - $currentDate is after $endDate, so any < have no sense
    - I don't know if operator < work for DateTime objects

    try this:
    PHP Code:
    <?php
    $currentDate 
    = new DateTime('2008-03-10');
    $endDate     = new DateTime('1224-03-10');

    // while($currentDate < $endDate) {
      
    echo $currentDate->format('Y-m-d') . ' till '
      
    $currentDate->modify('+784 Years');
      echo 
    $currentDate->format('Y-m-d') . ' <br />';
    // }
    ?>
    best regards

  • Users who have thanked oesxyl for this post:

    Mihai (03-11-2008)


  •  

    Posting Permissions

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