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

MaxSky
• 阅读 1492
// 代码使用 nesbot/carbon 包

// get last bootup time
exec('WMIC OS GET LastBootUpTime', $output);

$bootUpTime = current(explode('+', $output[1]));
$bootUpTime = Carbon::createFromFormat('YmdHis.u', $bootUpTime)->timestamp;

$bootedSeconds = Carbon::now()->timestamp - $bootUpTime;

echo "系统已运行:{$bootedSeconds} 秒";
点赞
收藏
评论区
推荐文章
Stella981 Stella981
2年前
CentOS 6.4 安装 media wiki 1.23.6(转)
准备:CentOS6.4系统及Root或者sudo权限,系统正常连接网络使用到的软件:apache,mysqlserver,php,mediawiki,memcached软件包的安装首先,需要安装apache,php,mysqlserver,mysqlclient等相关软件包
Stella981 Stella981
2年前
Python之time模块的时间戳、时间字符串格式化与转换
Python处理时间和时间戳的内置模块就有time,和datetime两个,本文先说time模块。关于时间戳的几个概念时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。时间元组(struct_time),包含9个元素。 time.struct_time(tm_y
Stella981 Stella981
2年前
HIVE 时间操作函数
日期函数UNIX时间戳转日期函数: from\_unixtime语法:   from\_unixtime(bigint unixtime\, string format\)返回值: string说明: 转化UNIX时间戳(从19700101 00:00:00 UTC到指定时间的秒数)到当前时区的时间格式举例:hive   selec
Wesley13 Wesley13
2年前
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
Stella981 Stella981
2年前
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
Stella981 Stella981
2年前
Mac自带PHP启动php
Mac自带phpfpm,在终端执行phpfpm,会报如下错误:ERROR:failedtoopenconfigurationfile'/private/etc/phpfpm.conf':Nosuchfileordirectory(2)ERROR:failedtoloadconfigurationfile
Stella981 Stella981
2年前
Linux常用软件启动、停止、重启命令
一、PHP启动命令:/usr/local/php5/sbin/phpfpm停止命令:pkillphpfpm二、MySQL启动命令:/etc/init.d/mysqldstart停止命令:/etc/init.d/mysqldstop重启命令:/etc/
Stella981 Stella981
2年前
PHP+jQuery寥寥几行代码轻松实现百度搜索那样的无刷新PJAX的分页列表和导航链接
!(https://static.oschina.net/uploads/space/2016/1208/171419_U00R_561214.png)PHP寥寥几行代码轻松实现百度搜索那样的分页列表和导航链接,某些语言的拥趸哭晕在厕所.<?php$apparray('db_prefix''
Wesley13 Wesley13
2年前
PHP中的NOW()函数
是否有一个PHP函数以与MySQL函数NOW()相同的格式返回日期和时间?我知道如何使用date()做到这一点,但是我问是否有一个仅用于此的函数。例如,返回:2009120100:00:001楼使用此功能:functiongetDatetimeNow(){
Stella981 Stella981
2年前
C++笔记002:VS2010报错:LINK fatal error LNK1123 转换到 COFF 期间失败文件无效或损坏
 原创笔记,转载请注明出处!点击【关注】,关注也是一种美德~错误描述:1已启动生成:项目:FirstCode,配置:DebugWin321生成启动时间为2018/2/521:00:30。1InitializeBuildStatus:1 正在