首页 > 代码库 > moment.js 的简单应用
moment.js 的简单应用
moment.js :时间处理的组件
例子:moment.html
<!DOCTYPE html> <html> <head> <title>moment.js</title> <meta charset="utf-8"> <script type="text/javascript" src="jquery.min.js"></script> <script src="moment.min.js"></script> </head> <body> hi, I am moment. 以下是时间: <div class="www"> </div> <script > $(‘.www‘).html(moment().format()); //亦可 // function a(){ // $(‘.www‘).html(moment().format()); // } // a(); </script> </body> </html>
简单了解常用的用法。比如:
1)能把日期以常见的格式展示 如2016年5月3号 2016年05月03号 2016年05月03号 3时;
2)能获取两个时间的时间差,差的 年、月、日、时、分、秒;
3)当前时间往前100个小时是什么时间,往后100个小时是什么时间;
moment.js 的简单应用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。