Rumah > pembangunan bahagian belakang > tutorial php > PHP计算两个时间戳之差

PHP计算两个时间戳之差

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-07-29 09:06:37
asal
1519 orang telah melayarinya

PHP计算两个时间戳之差

<code><span>/**
     * 计算两个时间戳之差
     *<span> @param</span> $begin_time
     *<span> @param</span> $end_time
     *<span> @return</span> array
     */</span><span><span>function</span><span>timeDiff</span><span>( <span>$begin_time</span>, <span>$end_time</span> )</span>{</span><span>if</span> ( <span>$begin_time</span> $end_time ) {
            <span>$starttime</span> = <span>$begin_time</span>;
            <span>$endtime</span> = <span>$end_time</span>;
        } <span>else</span> {
            <span>$starttime</span> = <span>$end_time</span>;
            <span>$endtime</span> = <span>$begin_time</span>;
        }
        <span>$timediff</span> = <span>$endtime</span> - <span>$starttime</span>;
        <span>$days</span> = intval( <span>$timediff</span> / <span>86400</span> );
        <span>$remain</span> = <span>$timediff</span> % <span>86400</span>;
        <span>$hours</span> = intval( <span>$remain</span> / <span>3600</span> );
        <span>$remain</span> = <span>$remain</span> % <span>3600</span>;
        <span>$mins</span> = intval( <span>$remain</span> / <span>60</span> );
        <span>$secs</span> = <span>$remain</span> % <span>60</span>;
        <span>$res</span> = <span>array</span>( <span>"day"</span> => <span>$days</span>, <span>"hour"</span> => <span>$hours</span>, <span>"min"</span> => <span>$mins</span>, <span>"sec"</span> => <span>$secs</span> );
        Log::info(<span>$res</span>);
        <span>return</span><span>$res</span>;
    }</code>
Salin selepas log masuk
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了PHP计算两个时间戳之差,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan