Results 1 to 5 of 5

Thread: Date time format changes ?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    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?

  2. #2
    Addicted Member
    Join Date
    Nov 2001
    Location
    Liverpool, England
    Posts
    155
    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    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?

  4. #4
    Addicted Member
    Join Date
    Nov 2001
    Location
    Liverpool, England
    Posts
    155
    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?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    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
  •  



Click Here to Expand Forum to Full Width