{"id":453,"date":"2025-06-10T20:39:57","date_gmt":"2025-06-10T12:39:57","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/jcyy\/453.html"},"modified":"2025-06-10T20:39:57","modified_gmt":"2025-06-10T12:39:57","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8php%e4%b8%ad%e8%8e%b7%e5%8f%96%e5%bd%93%e5%89%8d%e6%97%b6%e9%97%b4%e6%88%b3","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/453.html","title":{"rendered":"\u5982\u4f55\u5728PHP\u4e2d\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u6233"},"content":{"rendered":"<p><body><\/p>\n<h2>&#20171;&#32461;<\/h2>\n<p>&#22788;&#29702;&#26085;&#26399;&#21644;&#26102;&#38388;&#22312;&#35768;&#22810;PHP&#24212;&#29992;&#31243;&#24207;&#20013;&#26159;&#19968;&#39033;&#24120;&#35265;&#30340;&#20219;&#21153;&#12290;&#26080;&#35770;&#26159;&#35760;&#24405;&#20107;&#20214;&#12289;&#23433;&#25490;&#20219;&#21153;&#36824;&#26159;&#35774;&#32622;&#23450;&#26102;&#22120;&#65292;&#20934;&#30830;&#39640;&#25928;&#22320;&#33719;&#21462;&#24403;&#21069;&#30340;&#26102;&#25139;&#37117;&#26159;&#33267;&#20851;&#37325;&#35201;&#30340;&#12290;<\/p>\n<h2>&#33719;&#21462;&#24403;&#21069;&#26102;&#38388;&#25139;<\/h2>\n<p>&#20026;&#20102;&#22312;PHP&#20013;&#31616;&#21333;&#22320;&#33719;&#21462;&#24403;&#21069;&#30340;Unix&#26102;&#38388;&#25139;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#20197;&#19979;&#20195;&#30721;&#65306;<code>time()<\/code>&#20989;&#25968;&#12290;&#27492;&#20989;&#25968;&#36820;&#22238;&#33258;Unix&#32426;&#20803;&#65288;&#26684;&#26519;&#23612;&#27835;&#26631;&#20934;&#26102;&#38388;1970&#24180;1&#26376;1&#26085;00:00:00&#65289;&#20197;&#26469;&#30340;&#24403;&#21069;&#26102;&#38388;&#65288;&#20197;&#31186;&#20026;&#21333;&#20301;&#65289;&#12290;<\/p>\n<pre><code>$currentTimestamp = time();\necho $currentTimestamp;\n<\/code><\/pre>\n<h2>&#20351;&#29992;DateTime&#31867;<\/h2>\n<p>&#19968;&#31181;&#26356;&#38754;&#21521;&#23545;&#35937;&#30340;&#26041;&#27861;&#26469;&#31649;&#29702;&#26085;&#26399;&#21644;&#26102;&#38388;&#26159;&#36890;&#36807;&#20351;&#29992;&#12290;<code>DateTime<\/code>class&#12290;&#20320;&#21487;&#20197;&#36890;&#36807;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#23454;&#20363;&#26469;&#33719;&#21462;&#24403;&#21069;&#26102;&#38388;&#25139;&#12290;<code>DateTime<\/code>&#28982;&#21518;&#65292;&#20351;&#29992;&#20102;&#23427;&#12290;<code>getTimestamp()<\/code>&#26041;&#27861;&#12290;<\/p>\n<pre><code>$date = new DateTime();\n$currentTimestamp = $date-&gt;getTimestamp();\necho $currentTimestamp;\n<\/code><\/pre>\n<h2>&#26684;&#24335;&#21270;&#26102;&#38388;&#25139;<\/h2>\n<p>&#22914;&#26524;&#20320;&#38656;&#35201;&#19968;&#20010;&#26684;&#24335;&#21270;&#30340;&#23383;&#31526;&#20018;&#32780;&#19981;&#26159;Unix&#26102;&#38388;&#25139;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#12290;<code>date()<\/code>&#20989;&#25968;&#12290;&#20316;&#20026;&#31532;&#19968;&#20010;&#21442;&#25968;&#25351;&#23450;&#25152;&#38656;&#26684;&#24335;&#12290;&#36825;&#37324;&#26159;&#22914;&#20309;&#20197;&#20154;&#31867;&#21487;&#35835;&#30340;&#24418;&#24335;&#33719;&#21462;&#24403;&#21069;&#26085;&#26399;&#21644;&#26102;&#38388;&#65306;<\/p>\n<pre><code>echo date('Y-m-d H:i:s');\n<\/code><\/pre>\n<h2>&#19982;&#26102;&#21306;&#30456;&#20851;&#30340;&#24037;&#20316;<\/h2>\n<p>&#22312;PHP&#20013;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#35774;&#32622;&#20840;&#23616;&#40664;&#35748;&#26102;&#21306;&#26469;&#24433;&#21709;&#25152;&#26377;&#26085;&#26399;\/&#26102;&#38388;&#20989;&#25968;&#30340;&#34892;&#20026;&#12290;<code>date_default_timezone_set()<\/code>&#36825;&#20250;&#24433;&#21709;&#21040;&#35832;&#22914;&#30340;&#21151;&#33021;&#12290;<code>date()<\/code>and the<code>DateTime<\/code>&#23545;&#35937;&#12290;<\/p>\n<pre><code>date_default_timezone_set('America\/New_York');\necho date('Y-m-d H:i:s');\n<\/code><\/pre>\n<p>Sorry, I don&#8217;t understand. Could you please provide more context or clarify your question?<code>DateTime<\/code>&#23545;&#35937;&#65292;&#20320;&#21487;&#20197;&#36890;&#36807;&#23454;&#20363;&#21270;&#26102;&#25351;&#23450;&#26102;&#21306;&#12290;<\/p>\n<pre><code>$timezone = new DateTimeZone('Europe\/Paris');\n$date = new DateTime('now', $timezone);\necho $date-&gt;format('Y-m-d H:i:s');\n<\/code><\/pre>\n<h2>&#20197;&#24494;&#31186;&#20026;&#21333;&#20301;&#30340;&#26102;&#38388;&#25139;<\/h2>\n<p>&#23545;&#20110;&#38656;&#35201;&#26356;&#39640;&#31934;&#24230;&#30340;&#24212;&#29992;&#31243;&#24207;&#65292;PHP &#25552;&#20379;&#20102;&#12290;<code>microtime()<\/code>&#35201;&#33719;&#21462;&#24403;&#21069;&#26102;&#38388;&#25139;&#65288;&#21253;&#25324;&#24494;&#31186;&#65289;&#65292;&#21487;&#20197;&#20351;&#29992;&#20197;&#19979;&#20989;&#25968;&#65306;<br \/>\nimport time<\/p>\n<p>current_timestamp = int(time.time() * 1000000)<br \/>\n&#36825;&#26679;&#23601;&#21487;&#20197;&#24471;&#21040;&#19968;&#20010;&#21253;&#21547;&#27627;&#31186;&#32423;&#21035;&#30340;&#31934;&#30830;&#26102;&#38388;&#25139;&#20102;&#12290;<\/p>\n<pre><code>$timestampWithMicroseconds = microtime(true);\necho $timestampWithMicroseconds;\n<\/code><\/pre>\n<h2>&#20351;&#29992;strtotime&#20989;&#25968;<\/h2>\n<p>&#23545;&#19981;&#36215;&#65292;&#25105;&#26080;&#27861;&#29702;&#35299;&#24744;&#30340;&#38382;&#39064;&#12290;&#35831;&#25552;&#20379;&#26356;&#22810;&#20449;&#24687;&#25110;&#37325;&#26032;&#34920;&#36848;&#24744;&#30340;&#38382;&#39064;&#12290;<code>strtotime()<\/code>&#22312;&#22788;&#29702;&#23383;&#31526;&#20018;&#34920;&#31034;&#30340;&#26085;&#26399;&#21644;&#26102;&#38388;&#26102;&#65292;&#20989;&#25968;&#38750;&#24120;&#23453;&#36149;&#12290;&#23427;&#21487;&#20197;&#23558;&#19968;&#20010;&#23383;&#31526;&#20018;&#36716;&#25442;&#20026;Unix&#26102;&#38388;&#25139;&#12290;<\/p>\n<pre><code>echo strtotime('now');\n<\/code><\/pre>\n<h2>&#24102;&#26377;&#26102;&#38388;&#25139;&#30340;&#32531;&#23384;&#25511;&#21046;<\/h2>\n<p>&#26102;&#38388;&#25139;&#21487;&#20197;&#29992;&#26469;&#25511;&#21046;&#32531;&#23384;&#26426;&#21046;&#12290;&#20363;&#22914;&#65292;&#21521;JavaScript&#25110;CSS&#25991;&#20214;&#30340;URL&#28155;&#21152;&#26102;&#38388;&#25139;&#26597;&#35810;&#21442;&#25968;&#65292;&#21487;&#20197;&#38450;&#27490;&#22312;&#26356;&#26032;&#21518;&#27983;&#35272;&#22120;&#21152;&#36733;&#26087;&#29256;&#26412;&#12290;<\/p>\n<pre><code>echo '';\n<\/code><\/pre>\n<h2>&#25968;&#25454;&#24211;&#25805;&#20316;&#20013;&#30340;&#26102;&#38388;&#25139;<\/h2>\n<p>&#22312;&#25968;&#25454;&#24211;&#25805;&#20316;&#20013;&#65292;&#26102;&#38388;&#25139;&#20801;&#35768;&#24744;&#36319;&#36394;&#26356;&#25913;&#24182;&#32500;&#25252;&#26377;&#20851;&#25968;&#25454;&#20309;&#26102;&#25554;&#20837;&#12289;&#26356;&#26032;&#25110;&#21024;&#38500;&#30340;&#35760;&#24405;&#12290;&#36825;&#37324;&#23637;&#31034;&#20102;&#20351;&#29992;PDO&#21644;MySQLi&#30340;&#19968;&#20123;&#31034;&#20363;&#65306;<\/p>\n<pre><code>\/\/ With PDO\n$pdo-&gt;prepare('INSERT INTO table (column, created_at) VALUES (?, ?)')-&gt;execute(['value', date('Y-m-d H:i:s')]);\n\n\/\/ With MySQLi\n$query = 'INSERT INTO table (column, created_at) VALUES (?, ?)';\n$stmt = $mysqli-&gt;prepare($query);\n$stmt-&gt;bind_param('ss', $value, date('Y-m-d H:i:s'));\n$stmt-&gt;execute();\n<\/code><\/pre>\n<h2>&#24615;&#33021;&#25285;&#24551;<\/h2>\n<p>&#22312;&#22788;&#29702;&#39640;&#36127;&#36733;&#24212;&#29992;&#26102;&#65292;&#32771;&#34385;&#26085;&#26399;\/&#26102;&#38388;&#20989;&#25968;&#30340;&#24615;&#33021;&#24433;&#21709;&#38750;&#24120;&#37325;&#35201;&#12290;&#32531;&#23384;&#26102;&#38388;&#25139;&#25110;&#20351;&#29992;&#20869;&#32622;&#25968;&#25454;&#24211;&#20989;&#25968;&#21487;&#20197;&#25552;&#39640;&#24212;&#29992;&#31243;&#24207;&#30340;&#21534;&#21520;&#37327;&#12290;<\/p>\n<h2>&#32467;&#35770;&#12290;<\/h2>\n<p>PHP &#20013;&#20934;&#30830;&#33719;&#21462;&#24403;&#21069;&#26102;&#38388;&#25139;&#30340;&#33021;&#21147;&#23545;&#20110;&#35768;&#22810;&#24212;&#29992;&#31243;&#24207;&#26469;&#35828;&#33267;&#20851;&#37325;&#35201;&#12290;&#20174;&#22522;&#30784;&#21151;&#33021;&#21040;&#26356;&#22797;&#26434;&#30340;&#38656;&#27714;&#65292;&#36825;&#20010;&#33021;&#21147;&#37117;&#38750;&#24120;&#37325;&#35201;&#12290;<code>time()<\/code>&#23558;&#21151;&#33021;&#36716;&#25442;&#20026;&#38754;&#21521;&#23545;&#35937;&#30340;&#26041;&#27861;&#12290;<code>DateTime<\/code>&#31867;&#65292;PHP&#25552;&#20379;&#20102;&#26681;&#25454;&#39033;&#30446;&#38656;&#27714;&#33719;&#21462;&#26102;&#38388;&#25139;&#30340;&#22810;&#31181;&#26041;&#27861;&#12290;&#26377;&#20102;&#36825;&#20123;&#30693;&#35782;&#65292;&#24744;&#23601;&#21487;&#20197;&#22312;PHP&#24212;&#29992;&#31243;&#24207;&#20013;&#22788;&#29702;&#20219;&#20309;&#19982;&#26102;&#38388;&#30456;&#20851;&#30340;&#21151;&#33021;&#20102;&#12290;<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#20171;&#32461; &#22788;&#29702;&#26085;&#26399;&#21644;&#26102;&#38388;&#22312;&#35768;&#22810;PHP&#24212;&#29992;&#31243;&#24207;&#20013;&#26159;&#19968;&#038;#39..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[38],"tuisongtax":[],"class_list":["post-453","my1js","type-my1js","status-publish","hentry","my1js2nav-jcyy"],"acf":{"qian_art_seotitle":"","qian_art_seotitle_source":{"label":"SEO\u6807\u9898","type":"text","formatted_value":""},"qian_art_seokws":"","qian_art_seokws_source":{"label":"SEO\u5173\u952e\u8bcd","type":"text","formatted_value":""},"qian_art_stzhong":"","qian_art_stzhong_source":{"label":"\u4e2d | \u77ed\u6807\u9898","type":"text","formatted_value":""}},"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js\/453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/types\/my1js"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/media?parent=453"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=453"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=453"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}