Date Format

Discussion in 'ASP .Net' started by Jason MacKenzie, Feb 4, 2005.

  1. I have a question regarding date formatting. I have a page that shows the
    date incorrectly locally but correctly on the server yet the regional
    settings appear to be the same.

    I have a calendar control on the page that when clicked populates a text box
    with 04/02/2005. Yet I have a html button that uses vbscript to populate
    the same button with the value of NOW and I get 2/4/2005 10:41:38 AM.

    I have my regional settings set to US and the short date format reads
    2/4/2005.

    I'm not sure what the problem may be.

    Any help is appreciated,

    Jason MacKenzie
    Jason MacKenzie, Feb 4, 2005
    #1
    1. Advertising

  2. Jason MacKenzie

    Karl Seguin Guest

    Jason:
    Your VbScript is running on the client, so obviously the client's setting
    are being used to control the format. Your ASP.Net is run on the server,
    so, by default, the server's settings are used.

    This can be changed by setting the thread's culture via:
    System.Threading.Thread.CurrentThread.CurrentCulture for example:
    doing: System.Threading.Thread.CurrentThread.CurrentCulture = new
    CultureInfo("fr-CA"); would format the date in Canadian French.

    Check out the basics outlined here:
    http://openmymind.net/localization/index.html#before

    Oh, and you can get the user's culture via Request.UserLanguages[0]
    http://msdn.microsoft.com/library/d...stemwebhttprequestclassuserlanguagestopic.asp

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Jason MacKenzie" <> wrote in message
    news:...
    >I have a question regarding date formatting. I have a page that shows the
    >date incorrectly locally but correctly on the server yet the regional
    >settings appear to be the same.
    >
    > I have a calendar control on the page that when clicked populates a text
    > box with 04/02/2005. Yet I have a html button that uses vbscript to
    > populate the same button with the value of NOW and I get 2/4/2005 10:41:38
    > AM.
    >
    > I have my regional settings set to US and the short date format reads
    > 2/4/2005.
    >
    > I'm not sure what the problem may be.
    >
    > Any help is appreciated,
    >
    > Jason MacKenzie
    >
    >
    >
    Karl Seguin, Feb 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,155
    Janaka
    Feb 18, 2004
  2. DC
    Replies:
    5
    Views:
    3,004
    Brendan Reynolds
    Jul 1, 2005
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,244
    Michael Borgwardt
    May 30, 2004
  4. Chu
    Replies:
    3
    Views:
    4,184
    Shawn
    Aug 15, 2006
  5. Josh Sharpe
    Replies:
    1
    Views:
    205
    Brian Candler
    Sep 21, 2010
Loading...

Share This Page