JavaScriptSerializer 时间格式化
时间格式化
Model m = new Model { Id = , Dt = DateTime.Now };
JavaScriptSerializer js = new JavaScriptSerializer();
string str = js.Serialize(m);
str = Regex.Replace(str, @"\\/Date\((\d+)\)\\/", match =>
{
DateTime dt = new DateTime(, , );
dt = dt.AddMilliseconds(long.Parse(match.Groups[].Value));
dt = dt.ToLocalTime();
return dt.ToString("yyyy-MM-dd HH:mm:ss");
});
Response.Write(str);
//{"Id":1,"Dt":"2011-08-17 17:38:47"}
JavaScriptSerializer 时间格式化的更多相关文章
- strftime 日期时间格式化
strftime() 函数根据区域设置格式化本地时间/日期,函数的功能将时间格式化,或者说格式化一个时间字符串. size_t strftime(char *strDest,size_t maxsiz ...
- javascript 时间格式化
添加扩展 //时间格式化扩展Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1 ...
- js时间格式化
const formatDate = timestamp => { const date = new Date(timestamp); const m = date.getMonth() + 1 ...
- js对特殊字符转义、时间格式化、获取URL参数
/*特殊字符转义*/ function replace_html(str) { var str = str.toString().replace(/&/g, "&" ...
- 特殊字符转义&时间格式化&获取URL参数
/*特殊字符转义*/ function htmlspecialchars (str) { var str = str.toString().replace(/&/g, "&& ...
- 【AspNetCore】【WebApi】扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat)
扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat) 一.背景 大家在使用WebApi时,会用到DateTime为参数,类似于这 ...
- EasyUI Datagrid Datetime(EasyUI DataGrid 时间格式化)
EasyUI DataGrid 时间格式化 方法一: var Common = { //EasyUI用DataGrid用日期格式化 TimeFormatter: function (value, re ...
- js Date 时间格式化的扩展
js Date 时间格式化的扩展: Date.prototype.format = function (fmt) { var o = { , //月 "d+": this.getD ...
- SqlServer时间格式化
最近用的SqlServer比较多,时间格式化老是忘记,现整理如下:(来源于网上,具体来源地址忘记了,归根到底MSDN吧) SELECT CONVERT(varchar(50), GETDATE(), ...
随机推荐
- 【LeetCode】93. Restore IP Addresses
Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...
- SpringBoot优化内嵌的Tomcat ---设置MaxConnections
使用kill -9杀掉springboot应用后,立马java -jar重启,会报错,需要等待一段时间才能启动成功,报错的原因是:/tmp/tomcat-docbase.474979491043437 ...
- python学习笔记——线程threading (一)
1 线程threading 1.1 基本概述 也被称为轻量级的进程. 线程是计算机多任务编程的一种方式,可以使用计算机的多核资源. 线程死应用程序中工作的最小单元 1.2 线程特点 (1)进程的创建开 ...
- GL_总账会计科目追寻SLA及子模组
相信做总账的学友们,一般很多时间都会花费在查询日记账的来源,因为R12多了一个SLA模组,又有些增加了追溯日记账的难度,个人整理了一下 11i过账方式: 子模组-> 总账 (Post Journ ...
- Retrofit2使用初探
首先需要导入这样两个包 compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' compile 'com.squareup.retrofit2:co ...
- Codeforces Round #263 (Div. 2) proC
题目: C. Appleman and Toastman time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Xcode6:解决_NSURLAuthenticationMethodServerTrust异常问题
一.在使用Xcode6进行执行项目时.发现程序直接Crash了,控制台信息例如以下: dyld: Symbol not found: _NSURLAuthenticationMethodServerT ...
- mac 安装android sdk
1.下载sdk http://www.androiddevtools.cn/ 2.解压下载文件到目标文件夹 tar -xzvf android-sdk_r24.4.1-macosx.zip /User ...
- 让easyui的datagrid的field支持属性的子属性(field.childfield)
如果不修改后台返回的数据格式,就只能修改easyui的源代码了. 首先在easyui的源代码中找到下面的部分,VS可以用 “var.*_.+=.*_.+\[.*_.+\];” 这个正则表达式来查找,会 ...
- mac下为什么光标按方向键只能一个字一个字地蹦
系统偏好设置-键盘 把按键重复拉到最快,重复前延迟拉到最短