The450Man 0 Posted September 24, 2015 Report Share Posted September 24, 2015 Say I have the day number of the year. How can I generate the date from that? EX. Todays daynumber is 265 How can I get the output 9/23/2015? Quote Link to post Share on other sites
deliter 203 Posted September 24, 2015 Report Share Posted September 24, 2015 I got this off of stackoverflow, the date object is Javascript is very complicated,I dont know how the code works,but it seems to be accuratetoday is the 267th day of the year as per http://www.epochconverter.com/epoch/daynumbers.php if you want some sort of calculator for different time periods try this define $dayNum(#day, #month, #year) { run javascript("function dayNo(y,m,d)\{ return --m>=0 && m<12 && d>0 && d<29+( 4*(y=y&3||!(y%25)&&y&15?0:1)+15662003>>m*2&3 ) && m*31-(m>1?(1054267675>>m*3-6&7)-y:0)+d; \}") set(#today, $eval("var todayIs = dayNo({#year},{#month},{#day}) todayIs"), "Local") return(#today) } set(#days, $dayNum(24, 09, 2015), "Global") or just a function to return today without input set(#today, $eval("function dayNo(y,m,d)\{ return --m>=0 && m<12 && d>0 && d<29+( 4*(y=y&3||!(y%25)&&y&15?0:1)+15662003>>m*2&3 ) && m*31-(m>1?(1054267675>>m*3-6&7)-y:0)+d; \} function dayOfTheYear()\{ var myTime = new Date() return dayNo(myTime.getYear(),myTime.getMonth()+1,myTime.getDate()) \} var todayIs = dayOfTheYear() todayIs "), "Global") Quote Link to post Share on other sites
Enigma 78 Posted September 24, 2015 Report Share Posted September 24, 2015 Also keep the Leap year in mind.Not sure whether that already has been integrated within that js code. Quote Link to post Share on other sites
deliter 203 Posted September 24, 2015 Report Share Posted September 24, 2015 Also keep the Leap year in mind.Not sure whether that already has been integrated within that js code.thanks Yeah I didn't think of that but luckily the guy who wrote that code,did set(#days, $dayNum(31, 12, 2012), "Global") Quote Link to post Share on other sites
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.