Aureole Posted February 4, 2008 Share Posted February 4, 2008 I'm creating a little Grease Monkey add-on for Firefox, for a Website that shows all times in PST. I want to search for all instances of: <li class="date">*</li> Then replace the date/time there-in with a new date, depending on the user's time-zone. An example of what the date looks like is "02.04.2008 11:10 AM PST" i.e.: <li class="date">02.04.2008 11:10 AM PST</li> I REALLY don't know where to start. Is this even possible? If someone can help me out then it'd be much appreciated. Normal Javascript is fine, however if you feel it'll make your life easier and you are familiar with it, then jQuery would be great. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 4, 2008 Share Posted February 4, 2008 The only sure way to detect time zones is sever side, not client side with javascript. Quote Link to comment Share on other sites More sharing options...
Aureole Posted February 5, 2008 Author Share Posted February 5, 2008 But surely Javascript can turn something like "02.04.2008 11:10 AM PST" into a time-stamp, then that time-stamp can be manipulated? I only need to turn the above into a time-stamp, then I will be able to achieve what I want to do; despite what you say. The script I'm writing only needs to convert to one time-zone, it could be a simple var... with the time-zone... then all it has to do is add ( subtract) a certain amount of seconds to (or from) the time-stamp. It's hard to explain, but if I can turn "02.04.2008 11:10 AM PST" into a time-stamp then the rest I can figure out myself. Any ideas? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted February 5, 2008 Share Posted February 5, 2008 your answer is on this page http://www.javascriptkit.com/jsref/date.shtml You'll need to run a getElementsByClassName function that you can either find or create to get all of the li with class of date. then do an innerHtml call on each one to return the pst date then run that through your custom date conversion function Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 5, 2008 Share Posted February 5, 2008 I only need to turn the above into a time-stamp, then I will be able to achieve what I want to do; despite what you say. Well good luck with that. Quote Link to comment Share on other sites More sharing options...
emehrkay Posted February 5, 2008 Share Posted February 5, 2008 phpQuestioner it is very possible, and easy, to do what he is trying to do. Did you look at the link i provided? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 5, 2008 Share Posted February 5, 2008 emehrkay the reason I said that is because Aureole was saying he/she was going to be able to do this no matter what I say. The javascript date functions can not accurately find the time zone of a person's current location. You need to use severs side scripting to accurately find times zone; as in PHP 5+ Time Zone Date And Time Function. I did not know original that Aureole wanted to convert a static date into another format; I thought he/she was trying to get the time zone for each web page visitor's location with javascript only. Quote Link to comment Share on other sites More sharing options...
Aureole Posted February 5, 2008 Author Share Posted February 5, 2008 Nope, I'm creating a User Script for Grease Monkey. A Website I visit has all their times in PST. I am going to make it so, someone can set a var in the User Script then it will convert all the times for them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.