|
-
Jan 29th, 2002, 08:55 AM
#1
Thread Starter
Fanatic Member
Date time format changes ?
I have an html page which has a date picker control. The format as displayed by the client is dd/mm/yyyy.
This date is then submitted to an asp page on the server. When i use
Code:
<%=request.item("datepicker")%>
the return value is in mm/dd/yyyy format.
I have checked the regional settings on the server, and the date is set to dd/mm/yyyy format.
So where is the change taking place?
-
Jan 29th, 2002, 11:54 AM
#2
Addicted Member
You could 'force' an input date into a specific format. First use the isDate function in client-side validation to ensure a valid date is entered in the first place, then use formatDateTime in the ASP. In your case it'd be:
Code:
tempDate = formatDateTime(request.item("datepicker"))
This should output the date as MM/DD/YYYY (but look up the formatDateTime function to see the different numerical arguments if it doesn't - I can't quite remember).
You can then rearrange the MM and DD by doing something like:
Code:
arrDate = split(tempDate)
'Assign temp vars values from the array
tempMonth = arrDate(0) 'Month as First array element(0)
tempDay = arrDate(1) 'Day as Second array element(1)
tempYear = arrDate(2) 'Year as Third array element(2)
strDate = tempDay & tempMonth & tempYear
Hope that helps.
Last edited by sweevo; Jan 29th, 2002 at 11:58 AM.
-
Jan 30th, 2002, 12:42 AM
#3
Thread Starter
Fanatic Member
I have done something similar, but this does seems quite messy. Is there not another solution.
The question still stands. At what stage is the date being changed?
-
Jan 30th, 2002, 04:49 AM
#4
Addicted Member
Doesn't the datepicker allow you to choose its format property (dataformat property or similar)? Or can you use Format(dd/mm/yyyy) on it or something?
-
Jan 30th, 2002, 07:26 AM
#5
Thread Starter
Fanatic Member
Yes it does have a format property. But it is the same as the formatdatetime function of vbscript. Also, as i display the date in the client browser, the format is dd/mm/yyyy. So the control has the correct value. It seems through, that it is changing when I read it in from the request object on the server. If I response.write the value, I get mm/dd/yyyy format. I have checked the regional settings on the server and the format is definitley dd/mm/yyyy. So why does my format change when reading it in from the request object?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|