rowmark
asked on
Add 30 minutes to datetime in Javascript
Hello,
I am using rainforestnet.com javascript calendar popup control. Say if the date is 11/15/2006 02:20 PM How do I add 30 minutes to this??
what I want is, whatever is the datetime I need to add 30 minutes to that.
Please help
thanks
I am using rainforestnet.com javascript calendar popup control. Say if the date is 11/15/2006 02:20 PM How do I add 30 minutes to this??
what I want is, whatever is the datetime I need to add 30 minutes to that.
Please help
thanks
// Assuming that the result date from the javascript popup is put into resultDate...
var delta = 30 * 60 * 1000; // Milliseconds in 30 minutes
var date = new Date( resultDate.parse() + delta );
var delta = 30 * 60 * 1000; // Milliseconds in 30 minutes
var date = new Date( resultDate.parse() + delta );
Hi,
try this..
<script language=javascript>
d=new Date()
Theday = d.getDay()+1
if(Theday < 10)
{
Theday = "0"+Theday}
TheMonth = d.getMonth()+1
if(TheMonth < 10)
{
TheMonth = "0"+TheMonth}
TheDate = Theday + "/" + TheMonth + "/" + d.getFullYear()
TheMinute = d.getMinutes() + 30
TheHour = d.getHours()
TheTime = TheHour + ":" +TheMinute
DateNow = TheDate + TheTime
</script>
R.K
try this..
<script language=javascript>
d=new Date()
Theday = d.getDay()+1
if(Theday < 10)
{
Theday = "0"+Theday}
TheMonth = d.getMonth()+1
if(TheMonth < 10)
{
TheMonth = "0"+TheMonth}
TheDate = Theday + "/" + TheMonth + "/" + d.getFullYear()
TheMinute = d.getMinutes() + 30
TheHour = d.getHours()
TheTime = TheHour + ":" +TheMinute
DateNow = TheDate + TheTime
</script>
R.K
ASKER
On click of this hyperlink
PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain. document.g etElementB yId('"+Cal .Ctrl+"'). value='"+C al.FormatD ate(PValue )+"';"+vTi meStr+";wi nMain.docu ment.getEl ementById( '"+Cal.NCt rl+"').val ue='"+Cal. FormatDate (PValue)+" ';"+vTimeS tr1+";wind ow.close() ;\">"+PVal ue+"</a>"+ vHLstr2+"< /font></td >";
Now this is Cal.FormatDate(PValue)+"'; "+vTimeStr 1+"; I need to add 30 minutes.
When I try to do this
var finalDateTime;
finalDateTime=new Date(Cal.FormatDate(PValue )+''+vTime Str1) ;
finalDateTime=finalDateTim e.setMinut es(x.getMi nutes()+30 )
Its throwing out errors
Please help
PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain.
Now this is Cal.FormatDate(PValue)+"';
When I try to do this
var finalDateTime;
finalDateTime=new Date(Cal.FormatDate(PValue
finalDateTime=finalDateTim
Its throwing out errors
Please help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks mplungjan. Even after doign that it is not working. It is throwing out errors
pls be more specific. the code I gave should not affect your code
If the date is valid, then adding 30 to it will not affect anything
If the date is valid, then adding 30 to it will not affect anything
What is the exact value in PValue?
rowmark:
Your TD code is ugly... :-).. no, no, make that "hard to read", yeah, that's better... :-)
It would be much better for you to simplify things, and create a function to do the things that you are trying to do in the in-line code.
It would also be better to make use of CSS to simplify your code.
Instead of using your very verbose
"<td " + vColor + " width=" + CellWidth + " align='center'><font face='verdana' size='2'" + vHLstr1 + ... + vHLstr2 + "</font>
define a style for your TD, and use something like:
"<td class='myClass'>" + ... + "<\/td>"
The style section of your <head> might look something like:
<style type='text/css'>
.myClass {
font-size : small;
font-style : Verdana;
color : Yellow;
background-color : Green;
}
</style>
Your TD code is ugly... :-).. no, no, make that "hard to read", yeah, that's better... :-)
It would be much better for you to simplify things, and create a function to do the things that you are trying to do in the in-line code.
It would also be better to make use of CSS to simplify your code.
Instead of using your very verbose
"<td " + vColor + " width=" + CellWidth + " align='center'><font face='verdana' size='2'" + vHLstr1 + ... + vHLstr2 + "</font>
define a style for your TD, and use something like:
"<td class='myClass'>" + ... + "<\/td>"
The style section of your <head> might look something like:
<style type='text/css'>
.myClass {
font-size : small;
font-style : Verdana;
color : Yellow;
background-color : Green;
}
</style>
x.setMinutes(x.getMinutes(