當前位置:生活全書館 >

學習教育

> php判斷時間戳是否為今天實例講解

php判斷時間戳是否為今天實例講解

本教程操作環境:windows7系統、PHP7.1版、DELL G3電腦

php判斷時間戳是否為今天實例講解

php判斷指定時間戳是不是今天的方法

實現思想:

使用date()格式化今天的日期,將其轉為“年月日”格式

使用date()格式化指定時間戳,將其轉為“年月日”格式

使用“==”運算符判斷是否相等,如果相等則指定時間戳是今天

實現代碼:

<?phpheader('content-type:text/html;charset=utf-8');$timestamp = time();  // 獲取一個時間戳if(date('Ymd', $timestamp) == date('Ymd')) {    echo '是今天';  }else{    echo '不是今天';  }?>

輸出結果

是今天

到此這篇關於php判斷時間戳是否為今天實例講解的文章就介紹到這了,希望大家以後多多支持好二三四!

<link rel="stylesheet" href="https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4f61d3594de/a4ea273683c8.css" type="text/css" /><link rel="stylesheet" href="https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4f61d3594de/a4ea303194c0eaf695827b59325e.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea2c3096c5e3db978c6e492c.js"></script> <script>SyntaxHighlighter.autoloader( 'applescript https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f3809476490d49a2a6da28.js', 'actionscript3 as3 https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f3a3d7.js', 'bash shell https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f0919772.js', 'coldfusion cf https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f19f887e6a2b59b9a0c4.js', 'cpp c https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f18094.js', 'obj-c objc https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7fd928e59.js', 'c# c-sharp csharp https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f1a38c7b5e2e.js', 'css https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f18397.js', 'delphi pascal https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f695886a4437.js', 'diff patch pas https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f699827c.js', 'erl erlang https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f782887b4239.js', 'groovy https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f5828b755a27.js', 'haxe hx https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7fa919c7f.js', 'java https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f891927b.js', 'jfx javafx https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f891927b6a06.js', 'js jscript javascript https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f8a38768452e5e.js', 'perl pl https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e2959676.js', 'php https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e29894.js', 'text plain https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e29c857342.js', 'py python https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e28990724330.js', 'ruby rails ror rb https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e0858663.js', 'scala https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e19385764d.js', 'sql https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e18188.js', 'vb vbnet https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e492.js', 'ps powershell https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7e29f937f5e0d42b5a3c6.js', 'xml xhtml xslt html https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7ea9d88.js', 'go golang https://js.how234.com/bdf1083093/a4fb0a2d90d5e7db978c76453942a4aad8/a4e1163081d9fc80c0d628/a4ea262b84dee7f59f.js' );</script> <script type="text/javascript"> SyntaxHighlighter.all(); </script>

標籤: 講解 實例 php 時間
  • 文章版權屬於文章作者所有,轉載請註明 https://shqsg.com/zh-hk/xuexijiaoyu/rwzvm5.html