Javascript Month and Day

<script language="javascript">
<!--
LaFecha = new Date()
month = LaFecha.getMonth()
month = (month * 1) + 1
day = LaFecha.getDate()
year = LaFecha.getYear()
if (month==1) {month = "January"}
else if (month==2) {month = "February"}
else if (month==3) {month = "March"}
else if (month==4) {month = "April"}
else if (month==5) {month = "May"}
else if (month==6) {month = "June"}
else if (month==7) {month = "July"}
else if (month==8) {month = "August"}
else if (month==9) {month = "September"}
else if (month==10) {month = "October"}
else if (month==11) {month = "November"}
else {month = "December"}
var grammar="";
if (day==1 || day==21 || day==31) {grammar="st"}
else if (day==2 || day==22) {grammar="nd"}
else if (day==3 || day==23) {grammar="rd"}
else {grammar="th"}

document.write("" + month + " " + day + "" + grammar + "");
// -->
</script>

Example




month day display Javascript


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site