Jump to content

show Good morning


mmarif4u

Recommended Posts

HI,

 

I want to know about time and date.

For example i want to send email to customer or want to set the

home header with time and date.

Now time and date function in ok i know how to do that.

But how can i guess or make a function that will show a user

that(Good morning,Good Afternoon,Good Evening) depends on time.

 

Any help will appreciated

thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/47990-show-good-morning/
Share on other sites

I think your best bet is using Javascipt. Since PHP is server side and the person's

browser is client side Javascript would work best...at least that is for displaying

it as a header on the page

 

If you want to send out emails to members of your site that are addressed using

"Good morning,Good Afternoon,Good Evening", I would think it's best to capture

their timezone in Javascript when they register and store that in a database where

you are storing their email address. Then each time the email is generated you can

customize each email to their specific timezone.

 

now that is my initial thought...keep in mind that while i am working on code for a project

I usually go through several revisions of "what the hell was I thinking" before coming up

with the correct method. :)

Link to comment
https://forums.phpfreaks.com/topic/47990-show-good-morning/#findComment-234519
Share on other sites

Thanks rikker for suggestion,

But i dont want to use javascript. Bcoz i did not feel compartable with javascript.

I have some idea in php but it always sya Good Morning.

 

I am not sure about it how to configure it.

<?php
if ((Time("G") >=5) AND (date("G") <= 11 )) echo "Good Morning!";
elseif ((Time("G") >=12) AND (date("G") <=18)) echo "Good Afternoon!";
elseif ((Time("G") >= 19) AND (date("G") <= 4)) echo "Good Evening!";
?>

Link to comment
https://forums.phpfreaks.com/topic/47990-show-good-morning/#findComment-234524
Share on other sites

I am no Javascript wiz either, actually i had to look some of this up to make sure I was not giving you something totolly wrong.

 

Here is what I did and worked for me.

Now you may want to change the times I used in this example. I have it set to say Good Afternoon after 6 PM (18)

 

 

<SCRIPT language="javascript">

    var dateNow = new Date();

    var clientHour = dateNow.getHours();

   

    if((clientHour >= 1) && (clientHour < 12)){

        document.write("Good Morning!")

    }else if((clientHour >= 12) && (clientHour < 18)){

        document.write("Good Afternoon!");

    }else if ((clientHour >= 18) && (clientHour <= 24)){

        document.write("Good Evening!");

    }

 

</SCRIPT>

Link to comment
https://forums.phpfreaks.com/topic/47990-show-good-morning/#findComment-234702
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.