js读取mongodb日期加8个月,再更新数据
来源:互联网 发布:腾讯手机管家数据恢复 编辑:程序博客网 时间:2024/05/17 02:34
function Todate(num) { //Mon Jan 01 2001 00:00:00 GMT+0800 num=num+""; print(num); var date = ""; var month = new Array(); month["Jan"] = "01"; month["Feb"] = "02"; month["Mar"] = "03"; month["Apr"] = "04"; month["May"] = "05"; month["Jun"] = "06"; month["Jul"] = "07"; month["Aug"] = "08"; month["Sep"] = "09"; month["Oct"] = "10"; month["Nov"] = "11"; month["Dec"] = "12";var str = num.split(" "); date = str[3] + "-" + month[str[1]] + "-" + str[2]+" "+str[4]; print(date); return date; }function padNumber(n) {return (n < 10 ? '0' : '') + n;}function isoDate(msSinceEpoch) {var d = new Date(msSinceEpoch);return d.getUTCFullYear() + '/' + padNumber(d.getUTCMonth() + 1) + '/' + padNumber(d.getUTCDate()) + ' ' +padNumber(d.getUTCHours()) + ':' + padNumber(d.getUTCMinutes()) + ':' + padNumber(d.getUTCSeconds()) + '.0';}function increaseDataMonth(collection, changeMonth) {//var changeMonth = 8;//var collection = db.ding;collection.find().forEach(function (e, i) {var oldtime = ISODate(e.lastchanged);var newtime = oldtime;newtime.setMonth(oldtime.getMonth() + changeMonth);e.lastchanged = isoDate(newtime);collection.save(e);})}function increaseDataMonth2(collection, changeMonth) {collection.find().forEach(function (e) { var ok=Todate(e.lastchanged);var oldtime = ISODate(ok);var newtime = oldtime;newtime.setMonth(oldtime.getMonth() + changeMonth);ok = isoDate(newtime);collection.update({"_id":e._id},{$set:{"lastchanged":ok}});// })}//use sharkExtermalBackUp;increaseDataMonth2(db.testSparktime, 8);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function Todate(num) { //2015/3/13 08:35:05 num=num+""; print(num); var date = "";var str = num.split("/");var month=str[1];if(month<10){month="0"+month;}var str2 = num.split(" ")[0];print(str2+" str2");var str3 = str2.split("/");var day=str3[2];if(day<10){day="0"+day;}print(day+" day"); date = str[0] + "-" + month + "-" + day+" "+num.split(" ")[1]; print(date); return date; }function padNumber(n) {return (n < 10 ? '0' : '') + n;}function isoDate(msSinceEpoch) {var d = new Date(msSinceEpoch);return d.getUTCFullYear() + '/' + (d.getUTCMonth() + 1) + '/' + d.getUTCDate() + ' ' +padNumber(d.getHours()) + ':' + padNumber(d.getUTCMinutes()) + ':' + padNumber(d.getUTCSeconds()) + '';}function hufan(collection, changeMonth) { print(11111111111111111);collection.find().forEach(function (e) { print(e.lastchanged+" lastchanged"); var ok=Todate(e.lastchanged); print(ok+" ok");var oldtime = ISODate(ok);var newtime = oldtime;newtime.setMonth(oldtime.getMonth() + changeMonth);print(newtime+" newtime");e.lastchanged = isoDate(newtime);print(e.lastchanged+" end");collection.update({"_id":e._id},{$set:{"lastchanged":e.lastchanged}});})}hufan(db.e3_order_goods_etl, 8);///////////////////////////////////////////////////////////////////////////////////////////////function padNumber(n) {return (n < 10 ? '0' : '') + n;}function isoDate(msSinceEpoch) {var d = new Date(msSinceEpoch);return d.getUTCFullYear() + '-' + (d.getUTCMonth() + 1) + '-' + d.getUTCDate() + ' ' +padNumber(d.getHours()) + ':' + padNumber(d.getUTCMinutes()) + ':' + padNumber(d.getUTCSeconds()) + '.0';}function hufan(collection, changeMonth) {collection.find().forEach(function (e) { var ok=e.lastchanged;var oldtime = ISODate(ok);var newtime = oldtime;newtime.setMonth(oldtime.getMonth() + changeMonth);e.order_created_earliest = isoDate(newtime);collection.update({"_id":e._id},{$set:{"lastchanged":e.order_created_earliest}});})}hufan(db.e3_order_goods, 8);
0 0
- js读取mongodb日期加8个月,再更新数据
- js 的日期加天数 或者加月
- JS日期数据加天数转化
- js操作日期函数的一系列简单问题(日期加一个月)
- JavaScript_日期加月计算
- js与java获取前3个月日期
- spark读取mongodb数据
- MongoDB数据更新
- [MongoDB]Update更新数据
- mongodb基础数据更新
- mongodb更新数据
- Mongodb更新数据
- Mongodb 更新数据
- 日期加时间js控件
- js日期加十分秒
- js 指定日期加一天
- Excel 读取数据,日期读取
- docker部署node及mongodb,node.js读取mongodb数据以Web显示给用户
- touch
- Android Studio(AS)-->导入项目
- u-boot1.1.6 saveenv命令提示 Error: start address not on sector boundary的解决
- shape黑线框背景
- OwnCloud安装及维护文档(基于linux CentOS6.5)
- js读取mongodb日期加8个月,再更新数据
- 公有密钥/私有密钥加密
- 扩展访问列表 IP TCP
- iOS 7,8,9 通讯录的操作
- Cygwin make 出错 permission denied
- 理解使用递归及堆栈的算法处理八皇后问题
- 通知机制
- Java多线程中join方法的理解
- ORACLE RMAN备份及还原