Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Friday, 17 December 2010

Format date based on client time zone using javascript and ASP.NET AJAX

At time you might want to format date based on the client's browser configuration of language. If you are using ASP.NET AJAX then you will have the provision of using Sys namespace.

Here is a sample snippet that show how to use it :-

function ToClientFormat(ClientDate) {
    var dt = new Date(ClientDate);
    return dt.localeFormat(Sys.CultureInfo.CurrentCulture.dateTimeFormat.FullDateTimePattern);

Now this will display the date as

Friday, December 10, 2010 11:07:05 AM

As shown you will be able to use Sys.CultureInfo.CurrentCulture.dateTimeFormat to get which ever the format you were interested in, refer to MSDN for more details Sys.CultureInfo.dateTimeFormat

“Make everything as simple as possible, but not simpler.”
– Albert Einstein


Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers