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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleSetting 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