IT Community - Software Programming, Web Development and Technical Support

Date format yymmdd

This is a discussion on Date format yymmdd within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... Can any one tell me how can i validate a date in this(yymmdd) format. Thanks in advance......


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 02-28-2008, 03:16 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default Date format yymmdd

Hi all...


Can any one tell me how can i validate a date in this(yymmdd) format.


Thanks in advance...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 02-28-2008, 03:27 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 235
Pvinothkumar is on a distinguished road
Default Re: Date format yymmdd

Hi all...

<script language="JavaScript">
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function isValidYYMMDD(yymmdd) {
yymmdd += '';
if (yymmdd.length != 6) return false;
if (yymmdd != ((yymmdd - 0) + '')) return false;

year = yymmdd.substring(0,2) - 0;
month = yymmdd.substring(2,4) - 1;
day = yymmdd.substring(4,6) - 0;

(year < 70) ? year += 2000: year += 1900;

var test = new Date(year,month,day);

if ( (y2k(test.getYear()) == year) &&
(month == test.getMonth()) &&
(day == test.getDate()) )
return true;
else
return false;
}

document.write(isValidYYMMDD('990229'));
</script>

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 03-03-2008, 08:07 PM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 125
GDevakii is on a distinguished road
Smile Re: Date format yymmdd

1)(e.g. 04/03/2008)
<script language="JavaScript"><!--
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

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


2)(e.g. 4 March 2008)
<script language="JavaScript"><!--
function makeArray()
{
for (i = 0; i<makeArray.arguments.length; i++)
this[i + 1] = makeArray.arguments[i];
}

var months = new makeArray('January','February','March','April','Ma y',
'June','July','August','September','October','Nove mber','December');
var date = new Date();
var day = date.getDate();
var month = date.getMonth() + 1;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

document.write(day + " " + months[month] + " " + year);
//--></script>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validate a date to be in the format dd/mm/yyyy itbarota HTML, CSS and Javascript Coding Techniques 1 02-25-2008 08:21 PM
Convert a date from YYMMDD to YYYYDDD itbarota HTML, CSS and Javascript Coding Techniques 1 02-20-2008 08:47 PM
How can I show the documents last modified date in the format: month, date, year, tim Pvinothkumar HTML, CSS and Javascript Coding Techniques 3 12-28-2007 04:58 AM
How do I format the Last-Modified date with javascript? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 10-12-2007 10:17 PM
How to convert a date to a globally accepted date format, in DOT NET 2005? Archer C# Programming 1 07-25-2007 02:21 AM


All times are GMT -7. The time now is 04:51 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0