LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-16-2003, 04:16 PM   #16
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65

Hopefully this time!
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Current Date and Time</TITLE>
</HEAD>
<BODY>
<FORM name="form1"><INPUT name="box1" type="text"><INPUT name="box2" type="text"></FORM>

<SCRIPT type="text/javascript" language="JavaScript">

time = new Date();
year = new String(time.getYear());
if(navigator.appName != "Microsoft Internet Explorer"){year = (year*1)+1900}
month = new String((time.getMonth() + 1));
date = new String(time.getDate());
hours = new String(time.getHours());
mins = new String(time.getMinutes());
secs = new String(time.getSeconds());
if(mins.length<2){mins = "0"+mins}
if(secs.length<2){secs = "0"+secs}
if(month.length<2){month = "0"+month}
if(date.length<2){date  = "0"+date}
if(mins < 10){minstwo = new String((mins*1)+50)}
else{minstwo = new String((mins*1)-10)}
if(minstwo.length<2){minstwo = "0"+minstwo}

// Config Starts
box1format = year+"-"+month+"-"+date+" "+hours+":"+mins+":"+secs;
box2format = year+"-"+month+"-"+date+" "+hours+":"+minstwo+":"+secs;
document.form1.box1.value = box1format;
document.form1.box2.value = box2format;
// Config Ends

</SCRIPT>
</BODY>
</HTML>
 
Old 04-16-2003, 04:20 PM   #17
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
excellent, one final problem


when the time is 21:05:00 and -10 is substracted, then we get 21:-5:00

i tried by setting 10 to 30, and this is the reuslts:

2003-04-16 21:20:19
2003-04-16 21:-10:19


thanks once again
 
Old 04-16-2003, 04:34 PM   #18
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Here you go:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Current Date and Time</TITLE>
</HEAD>
<BODY>
<FORM name="form1"><INPUT name="box1" type="text"><INPUT name="box2" type="text"></FORM>

<SCRIPT type="text/javascript" language="JavaScript">

time = new Date();
year = new String(time.getYear());
if(navigator.appName != "Microsoft Internet Explorer"){year = (year*1)+1900}
month = new String((time.getMonth() + 1));
date = new String(time.getDate());
hours = new String(time.getHours());
mins = new String(time.getMinutes());
secs = new String(time.getSeconds());
if(mins.length<2){mins = "0"+mins}
if(secs.length<2){secs = "0"+secs}
if(month.length<2){month = "0"+month}
if(date.length<2){date  = "0"+date}
if(mins < 10){
minstwo = new String((mins*1)+50);
if(hours == "00"){
hourstwo = "23";
}
else{
hourstwo = new String((hours*1)-1);
}
}
else{minstwo = new String((mins*1)-10)}
if(minstwo.length<2){minstwo = "0"+minstwo}

// Config Starts
box1format = year+"-"+month+"-"+date+" "+hours+":"+mins+":"+secs;
box2format = year+"-"+month+"-"+date+" "+hourstwo+":"+minstwo+":"+secs;
document.form1.box1.value = box1format;
document.form1.box2.value = box2format;
// Config Ends

</SCRIPT>
</BODY>
</HTML>
 
Old 04-16-2003, 04:41 PM   #19
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
thanks, but still problem:


2003-04-16 21:41:01
2003-04-16 21:-9:01

i changed the -10 to -50, to test, and here is the results!!!
 
Old 04-16-2003, 04:50 PM   #20
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Of course it will it is only set to take of 10 minute - if you want to take of more you will need to modify the +50 argument too
 
Old 04-16-2003, 04:54 PM   #21
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
ok, excellent. about the pop up calendar, is there any chance of helping me out please. i have a pop up one that only has the date. please.
 
Old 04-16-2003, 04:56 PM   #22
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
What EXCATLY do you want?
 
Old 04-16-2003, 04:59 PM   #23
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
Thanks,

a pop up calendar, that helps the user to input the date and time, instead of having to type 0000-00-00 00:00:00, he would simply click on this javascript pop up calendar, that displays, a list of options for the user to select!!!!

http://www.dynamicdrive.com/dynamici...opcalendar.htm

but with the time as well.

i really appeciate your help, thanks a million
 
Old 04-16-2003, 05:00 PM   #24
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
thanks.

there is this one as well:

http://www.dynamicdrive.com/dynamici...pcalendar2.htm
 
Old 04-16-2003, 05:24 PM   #25
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Well! The first one failed with Mozilla and the second one worked but there was no time. Why do you need them to select a time if it is automatically created? Can you not just use drop down elements in forms?
 
Old 04-16-2003, 05:41 PM   #26
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
hi

The reason for this, is because i am using the form values to query MySQL. i require date and time to query data. i know the second one does date only, but i would like to have time as well.

cheers
 
Old 04-16-2003, 06:05 PM   #27
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Quote:
Originally posted by david_ross
Can you not just use drop down elements in forms?
Is there a reason that this isn't viable?
 
Old 04-16-2003, 07:51 PM   #28
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
hi

how do you do that?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To call a new form from Current form in QT Desginer kiranbud Linux - Software 0 11-26-2005 12:56 AM
Html Form File Cottsay General 0 11-05-2005 02:30 PM
html question: form henrikanttonen Programming 4 08-13-2004 08:28 AM
Contact form on HTML Gerardoj Linux - General 1 03-26-2004 03:08 AM
problem with html form meluser Linux - Software 4 03-15-2003 01:28 PM


All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration