C#Js时间格式化问题简单实例
时间:2023-05-17 01:49:19
C# 后台:
.ToString("dd-MMM-yyyy", System.Globalization. DateTimeFormatInfo.InvariantInfo) eg : 29-Aug-2013
Js 前台:
monName = new Array( "Jan", "Feb" , "Mar", "Apr", "May" , "Jun", "Jul", "Aug" , "Sept", "Oct", "Nov" , "Dec")
Date.prototype.format = function (format) {
if (!format) {
format = "yyyy-MM-dd hh:mm:ss";
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, ( this.getFullYear() + "" ).substr(4 - RegExp.$1.length));
}
if (/(M+)/.test(format)) {
format = format.replace(RegExp.$1, (monName[ this.getMonth()] + "" ).substr(3 - RegExp.$1.length));
}
if (/(d+)/.test(format)) {
format = format.replace(RegExp.$1, ( "00" + this .getDate() + "").substr(( "" + this .getDate()).length));
}
return format;
};
function formatJsonDate(str) {
if (str != null &&str!='') {
return (new Date(parseInt(str.substring(str.indexOf( '(') + 1, str.indexOf(')' ))))).format("dd-MMM-yyyy");
}
else {
return '' ;
}
标签:C#,Js,时间格式化
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
处理java异步事件的阻塞和非阻塞方法分析
2023-04-16 05:06:01
![](https://img.aspxhome.com/file/2023/1/72341_0s.png)
spring boot使用sharding jdbc的配置方式
2022-02-16 00:29:15
图解Eclipse在线安装ADT插件过程
2021-10-14 16:46:14
![](https://img.aspxhome.com/file/2023/8/101818_0s.png)
Java实现多线程断点下载实例代码(下载过程中可以暂停)
2021-06-09 18:02:41
![](https://img.aspxhome.com/file/2023/9/108459_0s.png)
Android自定义播放器控件VideoView
2023-06-25 03:29:00
JavaWeb Servlet实现文件上传与下载功能实例
2023-06-16 16:41:27
![](https://img.aspxhome.com/file/2023/2/62532_0s.png)
如何用C#找出数组中只出现了一次的数字
2021-06-15 15:42:56
mybatis-plus 返回部分字段的解决方式
2023-03-25 14:45:04
![](https://img.aspxhome.com/file/2023/1/61281_0s.jpg)
Unity实现透视滑动列表
2022-04-10 20:15:40
![](https://img.aspxhome.com/file/2023/8/129638_0s.gif)
mvn中dependencyManagement的使用详解
2021-11-05 10:19:20
C# WinForm实现图片浏览器
2022-04-12 23:28:00
![](https://img.aspxhome.com/file/2023/6/92906_0s.jpg)
Android gradle打包并自动上传的方法
2022-01-23 06:50:37
![](https://img.aspxhome.com/file/2023/9/138909_0s.jpg)
java线程同步操作实例详解
2023-11-13 14:19:08
Java DecimalFormat 保留小数位及四舍五入的陷阱介绍
2023-11-09 04:49:33
C# Dynamic关键字之:解析dynamic就是Object
2022-09-16 15:08:16
![](https://img.aspxhome.com/file/2023/0/116620_0s.png)
SpringBoot搭建多数据源的实现方法
2022-07-02 18:57:04
![](https://img.aspxhome.com/file/2023/2/91542_0s.png)
springboot vue组件开发实现接口断言功能
2023-11-12 10:26:53
![](https://img.aspxhome.com/file/2023/9/61869_0s.gif)
Java实现通讯录管理系统项目
2022-11-17 02:41:03
![](https://img.aspxhome.com/file/2023/3/71903_0s.jpg)
java编写的文件管理器代码分享
2023-11-20 13:28:52
C#自定义针对URL地址的处理类实例
2022-09-12 16:54:02