function FormatDateTime(datetime, FormatType) /* FomatType takes the following values 1 - General Date = Friday, October 30, 1998 2 - Typical Date = 10/30/98 3 - Standard Time = 6:31 PM 4 - Military Time = 18:31 */ { var strDate = new String(datetime); if (strDate.toUpperCase() == "NOW") { var myDate = new Date(); strDate = String(myDate); } else { var myDate = new Date(datetime); strDate = String(myDate); } // Get the date variable parts var Day = new String(strDate.substring(0,3)); if (Day == "Sun") Day = "Sunday"; if (Day == "Mon") Day = "Monday"; if (Day == "Tue") Day = "Tuesday"; if (Day == "Wed") Day = "Wednesday"; if (Day == "Thu") Day = "Thursday"; if (Day == "Fri") Day = "Friday"; if (Day == "Sat") Day = "Saturday"; var Month = new String(strDate.substring(4,7)), MonthNumber = 0; if (Month == "Jan") { Month = "January"; MonthNumber = 1; } if (Month == "Feb") { Month = "February"; MonthNumber = 2; } if (Month == "Mar") { Month = "March"; MonthNumber = 3; } if (Month == "Apr") { Month = "April"; MonthNumber = 4; } if (Month == "May") { Month = "May"; MonthNumber = 5; } if (Month == "Jun") { Month = "June"; MonthNumber = 6; } if (Month == "Jul") { Month = "July"; MonthNumber = 7; } if (Month == "Aug") { Month = "August"; MonthNumber = 8; } if (Month == "Sep") { Month = "September"; MonthNumber = 9; } if (Month == "Oct") { Month = "October"; MonthNumber = 10; } if (Month == "Nov") { Month = "November"; MonthNumber = 11; } if (Month == "Dec") { Month = "December"; MonthNumber = 12; } var curPos = 11; var MonthDay = new String(strDate.substring(8,10)); if (MonthDay.charAt(1) == " ") { MonthDay = "0" + MonthDay.charAt(0); curPos--; } var MilitaryTime = new String(strDate.substring(curPos,curPos + 5)); var Year = new String(strDate.substring(strDate.length - 4, strDate.length)); document.write(strDate + ""); // Format Type decision time! if (FormatType == 1) strDate = Day + ", " + Month + " " + MonthDay + ", " + Year; else if (FormatType == 2) strDate = MonthNumber + "/" + MonthDay + "/" + Year.substring(2,4); else if (FormatType == 3) { var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM"; if (MilitaryTime.substring(0,2) > 12) strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM; else { if (MilitaryTime.substring(0,2) < 10) strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM; else strDate = MilitaryTime + AMPM; } } else if (FormatType == 4) strDate = MilitaryTime; return strDate; }
file: /Techref/language/asp/js/formatDateTime.htm, 2KB, , updated: 2008/2/2 12:33, local time: 2024/11/25 12:03,
3.145.9.200:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/techref/language/asp/js/formatDateTime.htm"> language asp js formatDateTime</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.