找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8954|回复: 0

[脚本] 时间字符串及时间戳的同步生成 [脚本 ]

[复制链接]
发表于 2017-1-13 15:51:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
<script>
{
:global timstring
:global unixstramp
:local timstr do={
:local Date [/system clock get date];
:local Year ([:pick $Date 7 11])
:local Month ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $Date 0 3]]);:set Month ($Month + 1);:if (1 = [:len $Month])  do={:set Month "0$Month"}
:local Day [:pick $Date 4 6]
:local nn [/system clock get time]
:set nn (([:pick $nn 0 2]) . ( [:pick $nn 3 5]) . ( [:pick $nn 6 8]))
:return   ("$Year$Month$Day$nn")
}
:set timstring [$timstr]
:local secs
:local days 0
:local year ([:tonum [:pick $timstring 0 4]])
:local month ([:tonum [:pick $timstring 4 6]])
:local day  ([:tonum [:pick $timstring 6 8]])
:local hh  ([:tonum [:pick $timstring 8 10]])
:local mm  ([:tonum [:pick $timstring 10 12]])
:local ss  ([:tonum [:pick $timstring 12  14]])
:local daysarr [:toarray "31,28,31,30,31,30,31,31,30,31,30,31"]
:local unix2017 1483200000
:if ($month > 1) do={
:for i from=1 to=$month do={
:set days ($days+$daysarr->($i-1))
}
}
:if ($year>2017) do={
:for i from=2017 to=($year-1) do={
:set days ($days+1)
}
}
:set days ($days+$day-1)
:set secs  ($hh*3600+$mm*60+$ss)
:set secs ($secs + $days*3600*24 + $unix2017)
:set unixstramp $secs
:put ($timstring . "  " .  $unixstramp)
}
</script>

主要功能是同步当前时间日期成时间戳,有需要的用,没有需要的绕过。

routeros
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-4-27 15:28 , Processed in 0.045280 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表