【phptime()的问题】教程文章相关的互联网学习教程文章

php – 如何使用COMPOSER_PROCESS_TIMEOUT?【代码】

我已经在CMD中输入了这个COMPOSER_PROCESS_TIMEOUT=9999 php composer.phar install我认为上面的命令将使用给定的超时设置安装Compser.但是它会出错:’COMPOSER_PROCESS_TIMEOUT’不会被识别为内部或外部命令,可运行程序或批处理文件. 然后我会跑composer create-project laravel/laravel --prefer-dist解决方法:在Windows中,您需要设置变量:set "COMPOSER_PROCESS_TIMEOUT=9999" php composer.phar install需要附上报价.

在启动过程的哪个阶段,PHP设置了REQUEST_TIME变量【代码】

如PHP documentation所述,$_SERVER超全局数组包含两个元素REQUEST_TIME和REQUEST_TIME_FLOAT,它们都包含不同精度级别的请求开始的时间戳. 我目前正在使用以下代码段来包含服务器在页面页脚中生成页面所花费的时间(以毫秒为单位):round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2);它返回一个准确的值(无法真正检查,但它似乎与浏览器开始加载页面的时间相匹配),但我想知道$_SERVER [‘REQUEST_TIME’]和$_SERVER [确...

php – 错误:类DateTime的对象无法转换为字符串【代码】

显示值时出错:$thedate = $row2['date']; echo $thedate;在php中,这是数据库中的值($thedate)是“2015-05-05 21:52:31.000” 如何格式化它才能在php页面上以字符串形式显示?目前它显示错误“类DateTime的对象无法转换为字符串”.解决方法:您有一个DateTime对象,因此您必须使用format()格式化输出,例如echo $thedate->format("Y-m-d");

php – DateTimeZone类中的奇怪内容【代码】

DateTimeZone类中有奇怪的常量class DateTimeZone {const UTC = 1024;const ALL = 2047;... }我试图找到有关它们的任何信息.也尝试过使用它们:$dtz = new DateTimeZone(DateTimeZone::UTC); // throws Exception with message // DateTimeZone::__construct(): Unknown or bad timezone (1024)要么$dt = new Datetime('2016-02-01 10:00:00', DateTimeZone::UTC); // throws Exception with message// DateTime::__construct() ex...

php – 有人可以解释日期(“YW”,strtotime(“2016-01-02”));返回“201653”?【代码】

date("YW", strtotime("2016-01-02")); returns “201653”一年没问题周从2015年开始解决方法:PHP符合日期:ISO-8601The purpose of this standard is to provide an unambiguous and well-defined method of representing dates and times, so as to avoid misinterpretation of numeric representations of dates and times, particularly when data are transferred between countries with different conventions for writing ...

php – 为什么timezonedb和tzdata之间的亚洲/迪拜时区缩写有所不同?【代码】

我正在使用php timezonedb 2017.2. 为什么在亚洲/迪拜时区返回04而不是消费税?虽然PHP tzdata内置的默认值返回GST.$dt = new DateTime('now', new DateTimezone('Asia/Dubai')); $dt->format('T'); // returns either GST or +04php -v = PHP 5.5.38(cli)(建于2016年10月25日18:30:32)解决方法:基本上,因为时区数据会随时间而变化.听起来timezonedb是最新的,但tzdata不是. 这一变化发生在IANA time zone data的2017a版本中. 从公告...

php – TIMESTAMPS相对于DATETIME字段有多常见?

我希望我的产品,就像其他所有网络产品一样,从我的数据库中提取数据信息并将其转换为用户的时区,然后再将其显示在页面上.我正在使用PHP和MySQL. 使用TIMESTAMP字段比使用DATETIME字段更常见吗? 从我的研究来看,似乎使用DATETIME字段,我不得不这样做 >以UTC格式存储所有日期信息>每次应用程序启动时调用date_default_timezone_set(‘UTC’)>使用基于当前日期/时间的date()创建的日期手动减去用户的UTC偏移小时数>从传递给date的现有...

php – UNIX时间记录Timezone吗?

我想问一下UNIX时间,UNIX时间记录Timezone吗? 我把我的托管从芝加哥/美国搬到了JST. 问题是我的整个MySQL数据库都有UNIX时间记录(芝加哥/美国时区) 我有一个PHP代码显示时间(前3天前,昨天等)当我搬到新服务器时,明天会说 为避免明天这样做,是否可以将服务器关闭一天以便与当前服务器的时区同步? 我担心UNIX时间不仅会记录日期和时间,还会记录时区… 我可以设置PHP.ini时区,但它会减慢我的Apache吗?解决方法:UNIX时间中的“0”是...

php – 有什么更好的方法来保存db中的日期而不是time()?

我习惯使用time()将db中的日期保存为INT(11).考虑到时间()的限制有没有更好的方法来保存? 我想不使用数据库自??己的DATE类型(以及所有db自己的日期函数). 谢谢解决方法:好的,从评论中我知道使用time()的问题在于我们希望将01/01/1970之外的日期表示为/ 2038范围. 在这种情况下,我认为最好将数据库的日期格式化为YmdHis,存储在BIGINT中(如果不需要时间,则只存储在INT中的Ymd).您可以使用date_create(“now”) – > format($fmt)而不...

PHP比较两个日期格式2011-05-16T09:39:14 0000(facebook datetime format)【代码】

在PHP中,我想以这种格式比较2个日期:2011-05-16T09:39:14 0000$datedeb="2011-05-18T01:25:18+0000"; $datefin="2011-05-16T09:39:14+0000";我有PHP5.1.6供您参考.解决方法:您可以使用PHP的strtotime功能.这会将它们转换为时间戳,这意味着您可以像普通数字一样比较它们$datedeb = strtotime("2011-05-18T01:25:18+0000"); $datefin = strtotime("2011-05-16T09:39:14+0000");if ($datedeb > $datefin) {//$datedeb is larger (l...

php – strtotime返回当前年份,当输入格式为YYYY且值大于1999时【代码】

我不确定这是一个错误,因为搜索后我找不到任何重复的经历 – 但是,这个让我难过. 虽然在一个(相当痛苦的)脚本中打算采取一堆自由文本记录并将它们转换为有用的日期记录,但我信任的朋友strtotime()似乎让我失望了. 出于测试目的,我将代码简化为:<?=date('Y', strtotime("1999"));?>输出显示:1999年<?=date('Y', strtotime("1981"));?>输出显示:1981年<?=date('Y', strtotime("2001"));?>输出显示:2012年<?=date('Y', strtotime(...

php – 致命错误:未捕获的异常’Exception’,消息’DateTime ::【代码】

帮助解决此错误Fatal error: Uncaught exception ‘Exception’ with message ‘DateTime::_construct() [datetime.–construct]: Failed to parse time string (–) at position 0 (-): Unexpected character’ in Z:\home\plati\www\view.php:110 Stack trace: #0 Z:\home\plati\www\view.php(110): DateTime->_construct(‘–‘) #1 {main} thrown in Z:\home\plati\www\view.php on line 110$newday = $a['dayz']; $endmonth =...

PHP datetime字段SELECT今天?【代码】

我今天无法获取我的select语句来过滤datetime列:我只需要rowcount(多少)$u_today = date('Y-m-d'); $query = mysql_query("SELECT * FROM wds_sec1tasks WHERE due_date = '$u_today'"); $u_rows = mysql_num_rows($query); echo $u_rows;我需要抓住日期时间的左边10个字符进行比较吗? SUBSTR(DUE_DATE,0,10)? 谢谢,JM解决方法:您必须首先在DATE中转换due_date,方法是这样做:SELECT * FROM wds_sec1tasks WHERE DATE(due_date)...

Javascript getTime到php日期【代码】

我有javascript使用getTime()将我视图中的日期转换为时间字符串.然后将其存储为我的选择表单中的选项值.一旦它传递给PHP,我该如何将其转换为php日期? 我已经做好了:echo date("m/d/Y", '1345618799000');1345618799000 = Tue Aug 21 2012解决方法:您使用PHP的date()功能:date("Format here (see documentation"), round($_POST["time_field"]/1000));更新了,谢谢Yoshi.

PHP错误的DateTime :: diff()返回错误的DateInterval【代码】

我有两个日期时间差异的问题.以下是显示DateInterval对象的命令行:php -r "\$a = new Datetime('first day of 4 months ago midnight'); \$b = new Datetime('first day of 1 month ago midnight'); var_dump(\$a->diff(\$b));"这里是DateInterval输出:class DateInterval#3 (15) {public $y => int(0)public $m => int(3)public $d => int(3)public $h => int(0)public $i => int(0)public $s => ...

TIME - 相关标签