Quantcast
Channel: Setting a greeting based on user's time (Good morning, good afternoon…) - Stack Overflow
Browsing all 7 articles
Browse latest View live

Answer by Angrej Kumar for Setting a greeting based on user's time (Good...

function greeting_msg() { $hour = date('H'); if ($hour >= 18) { $greeting = "Good Evening"; } elseif ($hour >= 12) { $greeting = "Good Afternoon"; } elseif ($hour < 12) { $greeting = "Good...

View Article



Answer by Ravuru Bhargav for Setting a greeting based on user's time (Good...

const now = new Date().getHours();switch (true) { case (now<=12): console.log("Good Morning");break; case (now>12 && now<16): console.log("Good Afternnon");break; case (now>=16...

View Article

Answer by RN Kushwaha for Setting a greeting based on user's time (Good...

$hour = date('H');if ($hour >= 20) { $greetings = "Good Night";} elseif ($hour > 17) { $greetings = "Good Evening";} elseif ($hour > 11) { $greetings = "Good Afternoon";} elseif ($hour <...

View Article

Answer by Md. Aftab Uddin Tohan for Setting a greeting based on user's time...

<?php /* This sets the $time variable to the current hour in the 24 hour clock format */ $time = date("H"); /* Set the $timezone variable to become the current timezone */ $timezone = date("e"); /*...

View Article

Answer by Prem Gurusamy for Setting a greeting based on user's time (Good...

<?php// I'm India so my timezone is Asia/Calcuttadate_default_timezone_set('Asia/Calcutta');// 24-hour format of an hour without leading zeros (0 through 23)$Hour = date('G');if ( $Hour >= 5...

View Article


Answer by Sampson for Setting a greeting based on user's time (Good morning,...

Base it on .getHours() of the date object. Using javascript's Date object will automatically use the user's local time, rather than the server-time:var now = new Date();alert( now.getHours() );A couple...

View Article

Setting a greeting based on user's time (Good morning, good afternoon…)

Can anyone extrapolate on how to implement a basic "good evening" or "good morning" based on the user's time setting? Perhaps PHP will fetch the server time, but I'm looking to greet the site visitor...

View Article
Browsing all 7 articles
Browse latest View live




Latest Images