Exforsys
+ Reply to Thread
Results 1 to 3 of 3

Date and time script in PHP

This is a discussion on Date and time script in PHP within the PHP forums, part of the Programming Talk category; Could some one give me some idea on how to implement date and time display and also greet the users ...

  1. #1
    Guptha_S is offline Member Array
    Join Date
    Jan 2006
    Answers
    47

    Date and time script in PHP

    Could some one give me some idea on how to implement date and time display and also greet the users according to time using php ?

    THanks

    Last edited by admin; 11-06-2006 at 11:47 AM.

  2. #2
    Christopher_BG is offline Junior Member Array
    Join Date
    Jan 2006
    Answers
    12
    display a message for the different times of the day

    <?php

    $hours = date("G"); //24 hour time without leading zeros. eg. 0 or 23
    if($hours >= 22 && $hours <= 3){
    echo "My your up late arn\'t you!";
    }elseif($hours >= 4 && $hours <= 7){
    echo "My your up rather early!";
    }elseif($hours >= 8 && $hours <= 12){
    echo "Good morning, and how are we today?";
    }elseif($hours >= 13 && $hours <= 17){
    echo "Good afternoon, are we having a nice day?";
    }elseif($hours >= 18 && $hours <= 21){
    echo "Good evening, hope you had a nice day.";
    }

    ?>


  3. #3
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124
    Christopher it was a great program. I had a try on the program and could understand the concept as well as get the output. Thanks for such replies.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...