js和jQuery格式化时间
2017-12-27 16:32
274 查看
js使用方法:
jQuery使用方法:
var now = new Date(1500541859000); var year = now.getFullYear(), month = now.getMonth() + 1, date = now.getDate(), hour = now.getHours(), minute = now.getMinutes(), second = now.getSeconds(); function p(s) { return s < 10 ? '0' + s: s; } var timeFormat = year + "-" + p(month) + "-" + p(date) + " " + p(hour) + ":" + p(minute) + ":" + p(second);
jQuery使用方法:
$.myMethode = { //定义一个方法formatTime formatTime: function(time){ var now= new Date(parseInt(time)); var year = now.getFullYear(), month = now.getMonth() + 1, date = now.getDate(), hour = now.getHours(), minute = now.getMinutes(), second = now.getSeconds(); timeFormat = year + "-" + $.numCheck.p(month) + "-" + $.numCheck.p(date) + " " + $.numCheck.p(hour) + ":" + $.numCheck.p(minute) + ":" + $.numCheck.p(second); return timeFormat; } } $.numCheck = { //定义一个方法 p: function(s){ return s < 10 ? '0' + s: s; } } // 调用方法 var formateTime = $.myMethode.formatTime(1500541859000);
相关文章推荐
- js,jquery获取和格式化时间方法总结
- radio js toString bindable disabled evevt.srcElement. 多个空格变成一个空格 js格式化时间 [Bindable(true)] jquery img select
- js格式化时间
- js中格式化时间
- js 时间格式化
- 前端js、jQuery实现日期格式化、字符串格式化
- 浅谈jQuery.easyui的datebox格式化时间
- js 格式化时间日期函数小结
- js当前时间格式化
- JS格式化时间
- 用JavaScript(js)对时间格式化
- Js获取当前日期时间及其它格式化操作
- js格式化时间
- js date时间格式化扩展
- js时间格式化
- js时间格式化函数,支持Unix时间戳
- JS 格式化当前时间
- js时间格式化
- jquery.cookie.js存与取以及过期时间设置
- 四八、js封装格式化时间(将 Date 转化为指定格式的String)