Jump to content

Dates


monkeytooth

Recommended Posts

Maybe its cause I am just that tired and burnt out currently.. But I am trying to write a function to display

 

<day>, <month> <day number><suffix>, <year>

Example: Sunday, October 17th, 2010

 

However I seemed to screw myself up somewhere in the process and lost my <month> in the script. <month> is coming up and "undefined" but I can't figure it out, im burnt right now. I need an extra pair of eyes to help me out here, thanks in advance.

 

<script type="text/javascript">
<!--
var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate();
var sup = "";

if (curr_date == 1 || curr_date == 21 || curr_date ==31){sup = "st";}
else if (curr_date == 2 || curr_date == 22){sup = "nd";}
else if (curr_date == 3 || curr_date == 23){sup = "rd";}
else{sup = "th";}

var curr_month;
var curr_year;

if((d.getMonth()+6) > 12){curr_month = d.getMonth()+6;curr_year = d.getFullYear();}
else{curr_month = d.getMonth()-6;curr_year = d.getFullYear()+1;}

document.write(d_names[curr_day] + ", " + m_names[curr_month] + " " + curr_date + "<SUP>"+ sup + "</SUP>, " + curr_year);
//-->
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.