Topic
  • 1 reply
  • Latest Post - ‏2013-05-07T16:27:04Z by Dragos.Cojocari
MarcvanLint
MarcvanLint
57 Posts

Pinned topic Date maths in RPE

‏2013-04-23T20:00:09Z |

Hello World,

I want to iterate trough a year. Clearly you need to joggle with some Javascript. But a simple list of year-month-days does not seem to work in my case. As an example try the following snippet. It's not behaviing as you would expect (getting 1st of Jan), snippet of code in IE:

var dummy = new Date();
dummy.setFullYear(2013,1,1);
document.write( dummy.getFullYear()+"-"+dummy.getMonth()+"-"+dummy.getDay() );

or

 

<HTML>
<HEADER>
</HEADER>
<BODY>
<SCRIPT>
var dummy = new Date();
dummy.setFullYear(2013,1,1);
for (i=0;i<10;i++) {
 var myDate=new Date();
 myDate.setDate(dummy.getDate()+i);
 document.write( "<BR>"+myDate.getFullYear()+"-"+myDate.getMonth()+"-"+myDate.getDay() );
 }
</SCRIPT>
</BODY>
</HTML>

 

 

Updated on 2013-04-23T20:03:38Z at 2013-04-23T20:03:38Z by MarcvanLint
  • Dragos.Cojocari
    Dragos.Cojocari
    1647 Posts

    Re: Date maths in RPE

    ‏2013-05-07T16:27:04Z  

    Hey Marc,

    getDay returns the day of the week ( 0-6). You need to use getDate which returns the day of the month.

    See this for details:JS Date

    Regards,

        Dragos