date function

date function

Write a JavaScript program to read a date from user and perform the following, if entered value is date then perform the following 1. Display the day no from the date 2. Display the year from the date 3. Display the month from the date 4. Change the date to next day 5. Change the year to next year 6. change the month to next month

View Answers

March 12, 2011 at 5:41 PM

<html>
<script type="text/javascript">
function checkdate(){
var input=document.getElementById('mydate');
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ 
var returnval=false
if(!validformat.test(input.value))
alert("Invalid Date Format!")
else{ 
var monthfield=input.value.split("/")[0]
var dayfield=input.value.split("/")[1]
var yearfield=input.value.split("/")[2]
document.getElementById("no").value=dayfield;
document.getElementById("month").value=monthfield;
document.getElementById("year").value=yearfield;
document.getElementById("nextno").value=parseInt(dayfield)+1;
document.getElementById("nextmonth").value=parseInt(monthfield)+1;
document.getElementById("nextyear").value=parseInt(yearfield)+1;

var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Invalid Day, Month, or Year range!")
else
returnval=true
}
if(returnval==false) input.select()
return returnval
}
</script>
Enter date (mm/dd/yyyy):<input type="text" id="mydate" />
<input type="button" value="submit" onclick="checkdate();"><br />
<pre>
Day No     <input type="text" id="no">
Month      <input type="text" id="month">
Year       <input type="text" id="year">
Next Day   <input type="text" id="nextno">
Next Month <input type="text" id="nextmonth">
Next Year  <input type="text" id="nextyear">
</pre>
</html>









Related Tutorials/Questions & Answers:
date function
date function  Write a JavaScript program to read a date from user and perform the following, if entered value is date then perform the following 1. Display the day no from the date 2. Display the year from the date 3. Display
php date function - Date Calendar
php date function  Hi, I am new to PHP. I am trying to get date from database. But, every time the date under 1970, it changes to 1970. Im totally confuced.thank u in advance. For example : database: date format
Advertisements
The PHP Date() Function
The PHP Date() Function The PHP date() function is used for formatting... date and time. No installation is necessary for using this function. ADS... making it specific,  timestamp parameter is used in the date() function. e.g.
PHP Date function
PHP Date Function In this section we will show you the different formatting options available in the PHP Date function PHP date() function provides many... using date function as follows:</b>*/ echo ("<br>"
Mysql Date now function
Mysql Date now function       Mysql Date now function is useful when you want to return the current... an example from 'Mysql Date now function'. In this Tutorial we define a now
PHP date function
PHP Date() Function PHP Date() function is used to display the date and time in a précised format.  With the help of PHP date function you can format... provided by PHP in date function. Also, PHP provides number of functions
PHP date add function
PHP Add Date function - date_add or DateTime::add function The date_add function or DateTime::add function adds an amount of days, months, years, hours and seconds to a DateTime object. This function works in PHP 5.3.0 and above
PHP date_create_from_format function
date_create_from_format  function The date_create_from_format function is also known as DateTime::createFromFormat. This function returns new... according to the specified format. Parameters format Format accepted by date
ask how function jCalender - Date Calendar
ask how function jCalender  d, Halo friend, i want to ask how to make this script can run and call JCalender. I want to know how to make private this code.i has already insert plugin in my netbeans. try
How can we get second of the current time using date function?
How can we get second of the current time using date function?  How can we get second of the current time using date function
JavaScript Date Function
JavaScript Date Function Many language provide special functions for Date... the functions. JavaScript Date Function Example:ADS_TO_REPLACE_1 <html>...("<br/><b>Today's date is:</b><br/>"
PHP Date Function with Example
: Tuesday In PHP date() is a predefined function which returns a string value, depends on the parameter passed. To know more about date() function please visit... Write simple program to display the current date To develop the first
function
function  difference between function overloading and operator overloading
Mysql Date Parse
Mysql Date Parse       Mysql Date is used to parse the string date time in Date Format function and retrieve the date in specified format. Understand with ExampleADS_TO_REPLACE_1
date_format()
date_format() date_format alias DateTime::format function returns date formatted according to given format. It returns formatted date on success otherwise False on failure. Description on date_format() PHP public string DateTime::format
date_modify
date_modify() in PHP date_modify or DateTime::modify function modifies... , string $modify ) Parameters of Date Modify Function PHP object... by strtotime(). It returns the modify date time. Description public DateTime
PHP date_create
date_create () date_create function returns new DateTime object. It returns DateTime object on success or returns FALSE on failure. This functions was introduced in PHP 5.1.0. Description DateTime date_create ([ string $time
date_timestamp_set
date_timestamp_set date_timsestamp_set alias DateTime::setTimestamp function is used for setting the date and time based on an Unix timestamp. Syntax... unixtimestamp - Unix timestamp representing the date. Return Values
date_get_last_errors
date_get_last_errors date_get_last_errors alias DateTime::getLastErrors function returns the warnings and errors while parsing a date/time string... no parameter in this function. Return Values Returns array containing info
PHP Set Date
DateTime::setDate DateTime::setDate alias date_date_set function is used for resetting the current date of the DateTime object to a different date. It returns... $year, int $month, int $day ) DateTime date_date_set ( DateTime $object, int
date
date   how to insert date in database? i need coding
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  i want difference between the date entered in a jtextfield and the system date in java
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
SQL NOW() Function
;   NOW ( ) Function provides you the current date and time... ( ) The Now function returns a date and time that are stored in system... and time. The Now( ) function return you the current date and time in double
date_parse_from_format
  date_parse_from_format date_parse_from_format function returns associative array with detailed info about given date. It is used for accessing info... Parse Function PHP format - Format accepted by date() with some extras. date
PHP Date and Time
PHP Date and Time The PHP Date and Time function is massively used in setting date and time of the server, validating date and time and controlling the functions of the software. ADS_TO_REPLACE_1 The PHP date and Time
date_sub
(NOT P or T) can be any amount. Example of date_sub() Function in PHP: <...  date_sub date_sub alias DateTime::sub functions for subtracting.... It returns the modified DateTime. Description of PHP Date Sub FunctionADS
date
database table name birthday (DOB date); dob with DATE data type in database while...=d.getTime(); java.sql.Date date = new java.sql.Date(t); try { System.out.println(date); Class.forName("oracle.jdbc.OracleDriver"); con
date_timestamp_get
date_timestamp_get date_timestamp_get alias DateTime::getTimestamp function is used for getting the Unix timestamp.  Syntax public int DateTime::getTimestamp ( void ) Parameters This function has no parameters
date_sunrise
  date_sunrise date_sunrise function returns time of sunrise for a given day and location.  Description on PHP Date Sunrise Function mixed date_sunrise ( int $timestamp [, int $format= SUNFUNCS_RET_STRING [, float
DATE
DATE  I have the following as my known parameter Effective Date... of calcultion starts My question is how to find the date of Thursday This cycle... the date of all the thursdays of the given year. import java.util.*; import
Check Date in PHP
Check Date in PHP The Checkdate()ADS_TO_REPLACE_1 The PHP Checkdate function is used for validating the system date. It validate the Gregorian date. It returns 'True' if finds the specified date valid, otherwise it returns false
date_time_set
date_time_set date_time_set alias DateTime::setTime function resets... the modified date and time.  Syntax public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] ) DateTime date_time_set ( DateTime $object
NSLog Date example code
and then used the NSLog function to print the date on the console. // // ...;  today= [NSDate date];ADS_TO_REPLACE_5     NSLog(@"the current date is %@",today); } @endADS_TO_REPLACE_6  
date_sun_info
  date_sun_info() Function of PHP date_sun_info function returns.... Examples of Date Sun Info Function in PHP <?php $sun_info = date_sun_info... on success or False on failure.  Description on PHP date_sun_info
date_sunset
date_sunset() in PHP date_sunset function returns the sunset time... time in a specified format on success, or FALSE on failure. Syntax of date_sunset() in PHP mixed date_sunset ( int $timestamp [, int $format= SUNFUNCS_RET
date_isodate_setdate
date_isodate_setdate The ISO Date Format PHP or DateTime::setISODate function sets the date according to ISO 8601 standard - using weeks and day offsets... of ISO Date Format in PHP public DateTime DateTime::setISODate ( int $year, int
date_timezone_set
date_timezone_set() in PHP date_timezone_set alias DateTime::setTimezone function is used for setting the time zone for the DateTime object. It returns the modified DateTime.  Syntax on date_timezone_set() PHP public
date_timezone_get
PHP Date Timzezone Get The date_timezone_get alias DateTime::getTimezone function returns time zone relative to given DateTime. It returns DateTimeZone object on success or FALSE on failure. Syntax of date_timezone_get() in php
isNaN function
isNaN function  What does isNaN function do
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
function addValue
function addValue  i have question about the javascript the function addvalue script is working to add some name but is not save on the html so please resolve my problem what can i do for addvalue function will be to save
If function in PHP
If function in PHP  Hi, Provide me the example of If function in PHP. ThanksADS_TO_REPLACE_1   Hi, If function is PHP is used to check... of if() function in PHP:ADS_TO_REPLACE_2 $book="PHP"; if($book=="PHP"){ echo "Book
Calling a function
Calling a function  Hi, I have a function xyz() in php code. When a button is clicked it should execute that particular function for that i have... function function xyz() { } but this is not working can u tell me

Ads