PHP 取 Windows 启动时间及计算已启动秒数

1// 代码使用 nesbot/carbon 包 2 3// get last bootup time 4exec('WMIC OS GET LastBootUpTime', $output); 5 6$bootUpTime = current(explode('+', $output[1])); 7$bootUpTime = Carbon::createFromFormat('YmdHis.u', $bootUpTime)->timestamp; 8 9$bootedSeconds = Carbon::now()->timestamp - $bootUpTime; 10 11echo "系统已运行:{$bootedSeconds} 秒";
点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

CentOS 6.4 安装 media wiki 1.23.6(转)

准备:CentOS6.4系统及Root或者sudo权限,系统正常连接网络使用到的软件:apache,mysqlserver,php,mediawiki,memcached软件包的安装首先,需要安装apache,php,mysqlserver,mysqlclient等相关软件包

Python之time模块的时间戳、时间字符串格式化与转换

Python处理时间和时间戳的内置模块就有time,和datetime两个,本文先说time模块。关于时间戳的几个概念时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。时间元组(struct_time),包含9个元素。 time.struct_time(tm_y

HIVE 时间操作函数

日期函数UNIX时间戳转日期函数: from\_unixtime语法:   from\_unixtime(bigint unixtime\, string format\)返回值: string说明: 转化UNIX时间戳(从19700101 00:00:00 UTC到指定时间的秒数)到当前时区的时间格式举例:hive   selec

PHP创建多级树型结构

<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n

Ecshop用户中心的收藏列表里显示商品缩略图

1)、修改includes/lib\_clips.php文件将下面代码$sql'SELECTg.goods_id,g.goods_name,g.market_price,g.shop_priceASorg_price,'.修改为$sql'SELECTg.goods_id,g.goods_nam