Forum Moderators: open

Message Too Old, No Replies

Get the current hour (hour and minutes)?

and put the results in a checkbox?

         

Darkelve

9:49 am on Jun 14, 2006 (gmt 0)

10+ Year Member



Hi,

I want to know how I can get the current date and time and put the results in two text 'input fields':

in the first field should be the current hour value, in the second field, the current 'minutes' value.

I suppose I could use something like:

1. <input type="text" name="hours" maxlength="2" value="<%hourvalue%>" />?
2. <input type="text" name="minutes" maxlength="2" value="<%minutesvalue%>" />?

But what is the function to obtain the current hour and minutes?

Scally_Ally

2:54 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



use the time function to get the time in the format hh:mm:ss. You can then split this string into an array around the ":" and put the relevant array item in the textbox,

1. <input type="text" name="hours" maxlength="2" value="<%arrayValue(1)%>" />?
2. <input type="text" name="minutes" maxlength="2" value="<%arrayValue(2)%>" />?

garann

6:54 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



You could do it without splitting, too:


1. <input type="text" name="hours" maxlength="2" value="<%= DateTime.Now.ToString("HH") %>" />?
2. <input type="text" name="minutes" maxlength="2" value="<%= DateTime.Now.ToString("mm") %>" />?