monkeytooth Posted November 19, 2009 Share Posted November 19, 2009 Ok, don't know if this is simple or not, im not to familiar with javascript as of yet. But I need to define to variables. One being the current year. The other being the current year minus 50. then I need to print them onto the page in various locations. Anyone able to help me with that right quick? Quote Link to comment Share on other sites More sharing options...
Adam Posted November 19, 2009 Share Posted November 19, 2009 Is there a specific reason you need JS for this? You could generate the dates with PHP and use that to 'print them in various locations'? $thisyear = date("Y"); $yearsago = date("Y", strtotime("- 50 years")); If you really need to use JS you could even print the dates into the JS code..? Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted November 19, 2009 Author Share Posted November 19, 2009 I would love very much to do it in PHP however php vars don't transcribe to JavaScript vars and vise verse as far as I know. And what I wanting to do is have a date picker function that automatically adjusts the years within a certain range, so I don't have to go back in there and do it manually every so often. If it were so easy I would have been very happy :-D Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2009 Share Posted November 19, 2009 <script type="text/javascript"> date = new Date(); var curr_year = date.getYear(); var prev_year = curr_year - 50; </script> Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted November 19, 2009 Author Share Posted November 19, 2009 See, now by the examples I was going over via google search.. that just seemed like it would have been harder than that, thank you 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.