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? Link to comment https://forums.phpfreaks.com/topic/182119-dates/ 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..? Link to comment https://forums.phpfreaks.com/topic/182119-dates/#findComment-960840 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 Link to comment https://forums.phpfreaks.com/topic/182119-dates/#findComment-961018 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> Link to comment https://forums.phpfreaks.com/topic/182119-dates/#findComment-961022 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 Link to comment https://forums.phpfreaks.com/topic/182119-dates/#findComment-961096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.