|
-
Jul 10th, 2012, 07:38 PM
#1
Thread Starter
Hyperactive Member
how can i get the week number?
I have this code but it does not work
javascript Code:
<script language="javascript">
function script(){
var today = new Date();
var weekno = today.getWeek();
alert(weekno);
}
</script>
</head>
<body onload="script();">
</body>
-
Jul 11th, 2012, 04:28 AM
#2
Addicted Member
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:
<script type="text/javascript">
var Date = new Date();
var day = Date.getDate();
if(day<=7) {
alert("Its first week of month.");
} else if(day<=14) {
alert("Its second week of month.");
} else if(day<=21) {
alert("Its third week of the month.");
} else if(day<=28) {
alert("Its fourth week of the month.");
}
</script>
-
Jul 11th, 2012, 05:23 PM
#3
Thread Starter
Hyperactive Member
Re: how can i get the week number?
I want the week number of the year, ie: week 23
-
Jul 11th, 2012, 07:58 PM
#4
Re: how can i get the week number?
Datejs has methods for getWeek() and getISOWeek(), which is what I think you're looking for.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|