Hi there,

Can some one help me with the following problem. I need to pass the date to 2000-02-02 date format so that mysql will accept it. The following code is as follows;

function checkdate() {
var begDate = new Date(document.demoform.now.value);
var endDate = new Date(document.demoform.later.value);
var difDate = endDate.getTime() - begDate.getTime();
var days = difDate / (24*60*60*1000);

Can someone please help me with how to do this so that I get the 2000-01-01 date partern?

Your help will be really apprecaiated

8 Years
Discussion Span
Last Post by kwesiaryee

Just out of curiousity, why do you need to do this in javascript? you'll use server side code to actually do the insertion, and since users can just turn js off you need to perform important data validation on the server .:D


why are you using a text date,
Humans dont read the database, the computer does, computers do not need human readable data, they work better without it.
date as a timestamp is a numeric 10bytes per record to store a numeric string that represents date and time select * from table where date >date1 and date <date2 is so much faster to select date ranges when the dates are stored numeric
formatting is done on output echo date(Y-m-d,$date); to store a date and time
2002-10-21, 12:35pm 18bytes,
1035203700 10 bytes
not much on 1 row, but a lot on 1million rows,

for your actual question
Force the format
with 3 input/select boxes for Y M D , then concatenate the input values

Edited by almostbob: n/a


What I want to do is to calculate date difference between two fields so that i can present the result in another field and use that result to calculate the total price for a flight before the data is sent to the database...

Can i get help for this please

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.