locked
client system's data & time format in asp.net RRS feed

  • Question

  • User-1638078319 posted

     Hi friends,

    Is there any possibility to know the client system's date & time format from asp.net(with-out any activeX or other additional supported tools)?.. i got this doubt because the clients can access the web pages across the world so, i want to display a date time data from the database to client page as client's date-time format. i mean a client accessing from US can get mm/dd/yyyy format and a client accessing same page from India can get dd/mm/yyyy format on the web page.

    regards

    Prakash. 

    Wednesday, September 12, 2007 2:42 AM

Answers

  • User-1567482218 posted

    Given a valid Javascript date, you can show it in the client browser's regional format using the dateObject.toLocaleString() method.

    If you are concerned not just with the formatting but also want to show the actual date/time with respect to the user (as Indian Standard Time if it is India rather than the US server time), like FeedBurner does, consider storing the date in UTC (Coordinated Universal Time) Date/Time format & then display it in the local user's format with Javascript. For more info, check this code sample -  http://www26.brinkster.com/mvark/codegallery/show_UTCDateTime_as_local.aspx

    To generate a timestamp as UTC with Sql Server, use the GETUTCDATE() function instead of GETDATE ( ) & in C# you can use DateTime.UtcNow

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 12, 2007 3:00 AM