View Single Post
Old 11-11-2012, 07:13 AM   PM User | #1
ElizaKaye
New Coder

 
Join Date: Nov 2012
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
ElizaKaye is an unknown quantity at this point
trying to get day from date last modified

I need to get the day (Monday, Tuesday, etc) from date last modified code.

This code is working at the moment but not in htye correct format.

I would appreciate some help please


Code:
<script 
  type="text/JavaScript" 
  language="JavaScript">
<!-- 
//
// format date as dd-mmm-yy
// example: 12-Jan-99
//
function date_ddmmmyy(date)
{
  var d = date.getDate();
  var m = date.getMonth() + 1;
  var y = date.getYear();

  // handle different year values 
  // returned by IE and NS in 
  // the year 2000.
  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }

  // could use splitString() here 
  // but the following method is 
  // more compatible
  var mmm = 
    ( 1==m)?'Jan':( 2==m)?'Feb':(3==m)?'Mar':
    ( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
    ( 7==m)?'Jul':( 8==m)?'Aug':(9==m)?'Sep':
    (10==m)?'Oct':(11==m)?'Nov':'Dec';

	
  return "" +
    (d<10?"0"+d:d) + "-" +
    mmm + "-" +
    (y<10?"0"+y:y);
}


//
// get last modified date of the 
// current document.
//
function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;
 

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = "" + date_ddmmmyy(new Date(d1));
  }

  return s;
}

//
// finally display the last modified date
// as DD-MMM-YY
//
document.write( 
  "This page was updated on " + 
  date_lastmodified() );

// -->
</script>

Last edited by VIPStephan; 11-12-2012 at 10:23 AM.. Reason: corrected code BB tags
ElizaKaye is offline   Reply With Quote