Forum Moderators: open
var today = new Date()
var date = today.getDate()if(date>=15)
{
today.setMonth(today.getMonth()+1 % 12)
// this next doesn't quite fit, I know
// It goes back 1 day to the end of the prev month
today.setDate(0)
}
alert(today)
Anyway to format the date to MM/DD/YYYY format? This is your script printed instead of alerted.
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- //Begin
var today = new Date()
var date = today.getDate()
if(today>=15)
{
today.setMonth(today.getMonth()+1 % 12)
today.setDate(0)}
document.write(" "+today+" ")
//End -->
</SCRIPT>
/* Number method. rtn: String */
Number.prototype.prefix = function(n){
return new String(Math.pow(10,n)+this).substring(1)
}
/*-----------*/..code as before..
document.write
(
today.getDay().prefix(2) +"/"
+ today.getMonth().prefix(2) +"/"
+ today.getFullYear()
)