当前位置:网站首页>格式化时间
格式化时间
2022-07-21 05:05:00 【李子菜】
//格式化时间
function dateFtt(fmt,date){ //author: meizz
var o = {
"M+" : date.getMonth()+1, //月份
"d+" : date.getDate(), //日
"h+" : date.getHours(), //小时
"m+" : date.getMinutes(), //分
"s+" : date.getSeconds(), //秒
"q+" : Math.floor((date.getMonth()+3)/3), //季度
"S" : date.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
}
//调用
var createDate=dateFtt("MM月dd日 hh:mm",new Date(item["createDate"]));
使用
+'<span class="me_center_top_xinxi_time">'+createDate+'</span>'
边栏推荐
- 第五局 阿卡丽教学局 上
- 《C语言》2022山西专升本C语言知识点
- (好数对)一个数组的值赋给另一个数组
- MySQL installation failed
- 无法从“boost::shared_ptr<pcl::RangeImage>”转换为“const std::shared_ptr<const pcl::PointCloud<pcl::PointWit
- [PCB] 3.7V lithium battery -- 5V charge / discharge control circuit -- ip5306 -- drawing board notes
- Hetai 32 onenet WiFi module - Hetai MCU data cloud through mqtt protocol (I)
- 记录关于写程序的一些个小芝士~【持续更~】
- 深度剖析 string —— strlen & strtok
- OneNote plug-in, cloud expansion
猜你喜欢
随机推荐
1-10000水仙花数
MySQL installation failed
printf 详解 - 你所不知道的printf用法
1024 scientific counting method
codeforces 1647A Madoka and Math Dad
《C语言》2022山西专升本C语言知识点
第五局 阿卡丽教学局 下
我的第一篇博客
碎碎念 碎碎念 起稿
1009说反话
Pointnet++训练记录——Partseg
Account class
Open3d官网代码学习
使用MATLAB App Design 工具设计一个 简易App
useMemo和useCallback的区别以及使用场景
洛谷P1119 灾后重建(Floyd)
如何逐步匹配多幅点云
MySQL之账号管理.建库以及四大引擎
力扣中 26.删除有序数组中的重复项 88.合并两个有序数组 和189.旋转数组
Bert from introduction to practice notebook