different datetime format on the same web server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ya Ya

    different datetime format on the same web server

    I have developed a class library for a web application of mine.

    When compiling the code of the class library on one development machine and
    copy DLL to my web server I get dd/mm/yyyy date format when using the Now()
    function.

    When compiling the same code on another machine and copy the DLL to the same
    web server I get mm/dd/yyyy date format.

    I have not change the web.config of the application on the web server (I
    only replace the DLL).

    How is that possible?

    Can someone help here?



    Thanks

    ra294@hotmail.c om


  • Herfried K. Wagner [MVP]

    #2
    Re: different datetime format on the same web server

    "Ya Ya" <ra294@hotmail. com> schrieb:[color=blue]
    > I have developed a class library for a web application of mine.
    >
    > When compiling the code of the class library on one development machine[/color]
    and[color=blue]
    > copy DLL to my web server I get dd/mm/yyyy date format when using the[/color]
    Now()[color=blue]
    > function.
    >
    > When compiling the same code on another machine and copy the DLL to the[/color]
    same[color=blue]
    > web server I get mm/dd/yyyy date format.
    >
    > I have not change the web.config of the application on the web server (I
    > only replace the DLL).[/color]

    How do you convert the date to a string? Are you sure the currently
    executing thread's 'CurrentCulture ' is the same?

    --
    Herfried K. Wagner [MVP]
    <URL:http://dotnet.mvps.org/>


    Comment

    • Jim M

      #3
      Re: different datetime format on the same web server

      Look in the control panel under regional and language options or Regional
      settings. Make sure the date format is the same on both servers. You can
      also set this in your code to ensure you always get the format you want.
      Although this uses a page_load you should probably use this in global.asax

      imports system.globaliz ation

      Sub Page_Load(byval sender as object, e as eventargs)

      With System.Threadin g.Thread.Curren tThread
      Dim ci As New System.Globaliz ation.CultureIn fo("en-US")
      Dim dtf As DateTimeFormatI nfo = New
      System.Globaliz ation.DateTimeF ormatInfo
      dtf.ShortDatePa ttern = "MM.dd.yyyy "
      ci.DateTimeForm at = dtf
      .CurrentCulture = ci
      Response.Write( Now.ToShortDate String)
      End With

      End sub


      "Ya Ya" <ra294@hotmail. com> wrote in message
      news:OLGQ2LpyEH A.2876@TK2MSFTN GP12.phx.gbl...[color=blue]
      >I have developed a class library for a web application of mine.
      >
      > When compiling the code of the class library on one development machine
      > and copy DLL to my web server I get dd/mm/yyyy date format when using the
      > Now() function.
      >
      > When compiling the same code on another machine and copy the DLL to the
      > same web server I get mm/dd/yyyy date format.
      >
      > I have not change the web.config of the application on the web server (I
      > only replace the DLL).
      >
      > How is that possible?
      >
      > Can someone help here?
      >
      >
      >
      > Thanks
      >
      > ra294@hotmail.c om
      >[/color]


      Comment

      Working...