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
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
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
Share on other sites

Server side wont work because PHP's date function always returns the time on the server. So if your server is in the US while your client is in AU, you will be saying good morning where in fact you should be saying good evening.

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.