thankgodfortektips
Programmer
Hi All,
I now visual basic but not sure how to do this in javascript. I am trying to get a button that will take the current time and fill in a hour and minute field. I have figured most of it out, but when the hour or minutes is under 9 it returns 9 instead of 09.
So, what I need to do is if x is <9 then turn x into 09... sounds easy but cant figure it out. Below is what I have so far.
************************
var mydate= new Date()
var theyear=mydate.getFullYear()
var themonth=mydate.getMonth()+1
var thetoday=mydate.getDate()
var theHour=mydate.getHours()
var theMinute=mydate.getMinutes()
if (theHour<9){
theHour = "0" + theHour
}
************************
This above is giving errors...
Thanks in advance
I now visual basic but not sure how to do this in javascript. I am trying to get a button that will take the current time and fill in a hour and minute field. I have figured most of it out, but when the hour or minutes is under 9 it returns 9 instead of 09.
So, what I need to do is if x is <9 then turn x into 09... sounds easy but cant figure it out. Below is what I have so far.
************************
var mydate= new Date()
var theyear=mydate.getFullYear()
var themonth=mydate.getMonth()+1
var thetoday=mydate.getDate()
var theHour=mydate.getHours()
var theMinute=mydate.getMinutes()
if (theHour<9){
theHour = "0" + theHour
}
************************
This above is giving errors...
Thanks in advance