jquery 在时间上戳加一年。例如现在时间戳为 1472711659,在此基础上加上一年!谢谢!

jquery 在时间上戳加一年。例如现在时间戳为 1472711659,在此基础上加上一年!谢谢!,第1张

给你趴一个看看,先把时间戳转为时间,然后+1年,然后在转为时间戳
(function($) {
$extend({
myTime: {
/
当前时间戳
@return <int> unix时间戳(秒)
/
CurTime: function(){
return Dateparse(new Date())/1000;
},
/
日期 转换为 Unix时间戳
@param <string> 2014-01-01 20:20:20 日期格式
@return <int> unix时间戳(秒)
/
DateToUnix: function(string) {
var f = stringsplit(' ', 2);
var d = (f[0] f[0] : '')split('-', 3);
var t = (f[1] f[1] : '')split(':', 3);
return (new Date(
parseInt(d[0], 10) || null,
(parseInt(d[1], 10) || 1) - 1,
parseInt(d[2], 10) || null,
parseInt(t[0], 10) || null,
parseInt(t[1], 10) || null,
parseInt(t[2], 10) || null
))getTime() / 1000;
},
/
时间戳转换日期
@param <int> unixTime 待时间戳(秒)
@param <bool> isFull 返回完整时间(Y-m-d 或者 Y-m-d H:i:s)
@param <int> timeZone 时区
/
UnixToDate: function(unixTime, isFull, timeZone) {
if (typeof (timeZone) == 'number')
{
unixTime = parseInt(unixTime) + parseInt(timeZone) 60 60;
}
var time = new Date(unixTime 1000);
var ymdhis = "";
ymdhis += timegetUTCFullYear() + "-";
ymdhis += (timegetUTCMonth()+1) + "-";
ymdhis += timegetUTCDate();
if (isFull === true)
{
ymdhis += " " + timegetUTCHours() + ":";
ymdhis += timegetUTCMinutes() + ":";
ymdhis += timegetUTCSeconds();
}
return ymdhis;
}
}
});
})(jQuery);
调用边的
<script>
documentwrite($myTimeDateToUnix('2016-04-12 10:49:59')+'<br>');
documentwrite($myTimeUnixToDate(1460429399));
< /script>

以上就是关于jquery 在时间上戳加一年。例如现在时间戳为 1472711659,在此基础上加上一年!谢谢!全部的内容,包括:jquery 在时间上戳加一年。例如现在时间戳为 1472711659,在此基础上加上一年!谢谢!、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9575269.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存