C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
Today
    Last 7 Days more...






    Resources » Code Snippets » Javascript »

    Greeting message according to time


    Posted Date: 05 Nov 2009    Resource Type: Code Snippets    Category: Javascript
    Author: Abhisek PandaMember Level: Gold    
    Rating: 1 out of 5Points: 5



    The following javascript will display greeting message like, Good Morning, Good Afternoon and Good Evening according to the time.

    <html>
    <head>
    <title>Messages
    </title>
    </head>
    <body>
    <SCRIPT LANGUAGE="JavaScript">
    currentTime=new Date();
    //getHour() function will retrieve the hour from current time
    if(currentTime.getHours()<12)
    document.write("Good Morning");
    else if(currentTime.getHours()<17)
    document.write("Good Afternoon");
    else
    document.write("Good Evening");
    //End of JavaScript functions
    </SCRIPT>
    </body>
    </html>


    It will display 'Good Morning' if you run it between 12o'clock. After 12o'clock till 5pm it will display 'Good Afternoon' and after 5pm it will display 'Good Evening' on the web browser. You can embed this code in your webpage to greet a user according to time automatically.



    Responses

    Author: soniumesh    06 Nov 2009Member Level: Gold   Points : 0
    Hi,

    Hey what about good night.:)



    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Greeting message  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Display a DIGITAL CLOCK on the WebBrowser
    Previous Resource: Java script validation for mm/dd/yyyy date format.
    Return to Discussion Resource Index
    Post New Resource
    Category: Javascript


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use