Results 1 to 4 of 4

Thread: how can i get the week number?

  1. #1
    Addicted Member
    Join Date
    Apr 12
    Posts
    151

    how can i get the week number?

    I have this code but it does not work

    javascript Code:
    1. <script language="javascript">
    2.  
    3. function script(){
    4.     var today = new Date();
    5.     var weekno = today.getWeek();
    6.     alert(weekno);
    7. }
    8. </script>
    9. </head>
    10.  
    11. <body onload="script();">
    12.  
    13. </body>

  2. #2
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 12
    Posts
    140

    Re: how can i get the week number?

    If you want number of week in month you have to create it on different way because its not defined inside javascript by default.
    javascript Code:
    1. <script type="text/javascript">
    2. var Date = new Date();
    3. var day = Date.getDate();
    4. if(day<=7) {
    5. alert("Its first week of month.");
    6. } else if(day<=14) {
    7. alert("Its second week of month.");
    8. } else if(day<=21) {
    9. alert("Its third week of the month.");
    10. } else if(day<=28) {
    11. alert("Its fourth week of the month.");
    12. }
    13. </script>

  3. #3
    Addicted Member
    Join Date
    Apr 12
    Posts
    151

    Re: how can i get the week number?

    I want the week number of the year, ie: week 23

  4. #4
    Frenzied Member tr333's Avatar
    Join Date
    Nov 04
    Location
    /dev/st0
    Posts
    1,426

    Re: how can i get the week number?

    Datejs has methods for getWeek() and getISOWeek(), which is what I think you're looking for.
    Don't forget about rep points if you think a post has benefited you in any way.
    Just another Perl hacker,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •