Jump to content

Sending User's Time and Date to Page


FrankieB

Recommended Posts

Greetings everybody.

 

I am currently trying to do some time sensitive CSS on my website. What I am trying to do is find the local time on the users machine (not the server time) that is viewing my website, and then display a different style sheet depending on what time it is.

 

I tried using just Javascript and PHP, but I couldn't figure out how to get the user's time in Javascript and send it to the PHP code to choose which style sheet to display, and thats where I found out about Ajax.

 

I followed the basic tutorial on the website here, and I am not sure if I am doing this right.

 

The only difference is that I'm sending the hour (represented in military time) to the page via Ajax. The problem I have encountered is that the page doesn't get the variable at all. I've attributed this to the PHP all being parsed first, and then Ajax, so yes even though the page is getting the time, it doesn't matter because its after the fact.

 

Is there a better way I can go about doing this? Is there something I am doing wrong? How do I get the page to get the date first, and then load everything else?

 

Thanks for reading!

 

Note: I am new to all of this, so please bear with me. Wouldn't this make my life much easier as well if I all did this once with a session and then saved it there so that this Ajax doesn't have to load on every page?

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.