相关疑难解决方法(0)

如何比较两个DateTime字符串并以小时为单位返回差异?(bash shell)

我可以使用以下代码在php中执行此操作:

$dt1 = '2011-11-11 11:11:11';
$t1 = strtotime($dt1);

$dt2 = date('Y-m-d H:00:00');
$t2 = strtotime($dt2);

$tDiff = $t2 - $t1;

$hDiff = round($tDiff/3600);
Run Code Online (Sandbox Code Playgroud)

$hDiff 会在几个小时内给我结果.

如何在bash shell中实现上述功能?

unix linux shell

11
推荐指数
1
解决办法
5万
查看次数

标签 统计

linux ×1

shell ×1

unix ×1