Web Analytics Made Easy -
StatCounter Output current hour + 1 - CodingForum

Announcement

Collapse
No announcement yet.

Output current hour + 1

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Output current hour + 1

    I need to output the current hour plus 1 (e.g. if the hour was 1pm it would output 2pm).

    I current have
    PHP Code:
    <?php echo date("H:i:s"); ?>
    which outputs the current time, how would i increment it by an hour?

  • #2
    PHP Code:
    <?php echo date("H:i:s"mktime(date("H")+1date("i"), date("s"), date("m"), date("d"), date("Y"))); ?>

    Edit,
    If this is a timezone issue, you can use PHP to switch timezones for your server.


    .

    Comment


    • #3
      What it is is im outputting timezoens e.g. GMT 0 GMT +1 GMT +2 etc. Perhaps theres a better way of doing this what i didnt think of?

      Comment


      • #4
        Originally posted by mlseim View Post
        PHP Code:
        <?php echo date("H:i:s"mktime(date("H")+1date("i"), date("s"), date("m"), date("d"), date("Y"))); ?>

        Edit,
        If this is a timezone issue, you can use PHP to switch timezones for your server.


        .
        Or perhaps:

        PHP Code:
        <?php
        echo date("H:i:s",mktime()+3600); //3600 seconds = 1 hour.
        ?>
        Create accessible online surveys -::- Koobten.com - compare netbook prices and reviews -::- Affordable, reliable hosting for less than $20 per year
        Zend Certified Engineer

        Comment


        • #5
          Another solution:
          PHP Code:
          date'H:i:s'strtotime'+1 hour' ) ) 
          ZCE

          Comment


          • #6
            Thanks, all those work fine

            Comment


            • #7
              With date_default_timezone_set you specify a city within the timezone.
              There is a specific list of cities to choose from. Once you set that, all
              date functions after that (in the same script) will be using your timezone
              for all calculations.

              So, if you ask the user to pick a city from a list, you could set it that way too.

              I live near St. Paul, Minnesota ...
              So I would pick this timezone for me ...

              <?php
              date_default_timezone_set('America/Chicago');

              The main reason I do that is, my webhost server is on the East Coast,
              so their time is one hour ahead of me. I always force them to use my timezone
              if I'm concerned about specific hours within dates.


              .

              Comment


              • #8
                Ive set the timezone to my localtime, however im outputting a GMT timelist eg GMT +0 = hh:mm, GMT +1 = HH:MM etc so i needed to increment the time by one hour

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎