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
https://forums.phpfreaks.com/topic/39064-sending-users-time-and-date-to-page/
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.