Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Jul 31 In Java Category.

  
Question Answered By: Felix Gray   on Jul 31

Please always supply a subject for your questions. Also, have a search through
Yahoo Groups for JavaScript groups, which will be more useful for JavaScript
questions.

You can take a string entered by the user and convert it into a date field with:

var userDate = new Date (userString);

Note that the "new" is needed.

This will not validate that the string is a valid date format, nor will it be
entirely predictable about whether it's mm/dd/yy or dd/mm/yy format. You'll
remove ambiguity if you can get the format into yyyy/mm/dd.

You need to do a validation of the string before creating a date field.

Many sites are moving away from date strings and going to popup date pickers of
some sort if the date is to be converted to a date variable.

This one javascript.internet.com/calendars/date-picker.html will give you
a good example. This one http://www.calendarxp.net/ looks better. This
http://www.merlyn.demon.co.uk/js-date6.htm is a tutorial that will probably
provide you with more than you want.

You can also use drop-down lists: http://uts.cc.utexas.edu/~esuez/cal5.html

For more stuff, do a Google search with: javascript date picker.

The current date (actually the current date and time) can be obtained by:

var timeNow = new Date ();

You can simply do comparisons against this.

Share: 

 

This Question has 28 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Why we declare the constructor private? Or get search suggestion and latest updates.


Tagged: