开发者

Javascript globalization problem in asp.net

开发者 https://www.devze.com 2023-02-05 16:12 出处:网络
function GetDa开发者_JAVA百科teInLocalFormat(strDate) { if (strDate == undefined) return \"\" var dateVal = new Date(strDate));
function GetDa开发者_JAVA百科teInLocalFormat(strDate) {

if (strDate == undefined)
    return ""

var dateVal = new Date(strDate));
if (dateVal == null || isNaN(dateVal)) {    
    return "";
}

    return dateVal.localeFormat(Sys.CultureInfo.CurrentCulture.dateTimeFormat.ShortDatePattern);

}

I'm using the above function in Javascript display the date in localized format, new Date(strDate) is not working as expected.

Any suggestions to do date globalization in Javascript?


Try the Globalize library (originating from Microsoft, it was promoted as an official jQuery plugin, and then made available as a simple Javascript library).

0

精彩评论

暂无评论...
验证码 换一张
取 消