我可以使用以下代码在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中实现上述功能?