草庐IT

datetime_format

全部标签

php - 你能在 ""中回应 money_format() 吗?

我正在尝试回应以下内容echo"Thepriceismoney_format('$%i',$price)"但这实际上是echomoney_format('$%i',9.99)是否可以在""中回显money_format('$%i',$var_name)? 最佳答案 你需要连接运算符echo"Thepriceis".money_format('$%i',$price); 关于php-你能在""中回应money_format()吗?,我们在StackOverflow上找到一个类似的问题:

PHPAGI : Exec format error

运行phpagi时遇到问题:--Executing[123@DLPN_C:1]AGI("SIP/1000-00000001","hello_world.php")innewstack--LaunchedAGIScript/var/lib/asterisk/agi-bin/hello_world.phphello_world.php:Failedtoexecute'/var/lib/asterisk/agi-bin/hello_world.php':Execformaterror--Autofallthrough,channel'SIP/1000-00000001'statusis'UN

php - 解析年份时 strtotime 和 DateTime 给出错误的年份

$year=date('Y',strtotime("2012"));var_dump($year);//returns2013这发生在一台装有php5.2的旧服务器和一台装有php5.4的新服务器上服务器使用strtotime从类似2012-01-01或2012-01或2012的字符串中获取年份我还尝试使用$dt=newDateTime('2012')然后getTimestamp返回“1374516720”,即“Mon,22Jul201318:12:00格林威治标准时间”是什么导致了这个错误?在documentation它说strtotime只接受年份我不知道该怎么办...编辑:$ye

php - 为什么 DateTime::diff 在这些日期之间返回 0 天?

考虑以下测试用例:$start=newDateTime("2011-02-25");$end=newDateTime("2011-03-25");$interval=$end->diff($start);echo"INTERVAL=".$interval->format("%d");//Shouldgivemethe//intervalindays,right?echo"START=".$start->format("Y-m-d");echo"END=".$end->format("Y-m-d");结果是:INTERVAL=0diff()似乎声称2011年2月25日和2011年3月25

c# - PHP的number_format在C#中的等效功能是什么?

假设我有这些值:varupSize=365308443361.28;vardownSize=351897407979.52;varsize=upSize/downSize;在PHP中我可以这样做:number_format(size,3);输出将是:1.038如何在C#中使用string.Format()执行相同的操作? 最佳答案 是的,你可以使用string.Format:varupSize=365308443361.28;vardownSize=351897407979.52;varsize=upSize/downSize;st

php - 为什么使用 number_format() 会改变我的数值?

下面的代码给了我两个不同的输出:$number='1562798794365432135246';echo$number;echonumber_format($number);谁能解释一下?编辑:忘了说,上面给了我“15627987943654321352461,562,798,794,365,432,233,984”。请注意,最后六位数字完全不同,原因不明(我要求它做的只是插入千位分隔符)。 最佳答案 number_format(),asstatedbythePHPmanual,将一个float转换为一个带有逗号的数千组的字符串。

PHP DateTime::Diff "steals"一天

我想计算两天之间的日期差异。问题是当我计算天数时,计算中缺少一天(当天)。假设date1是20-12-2014,date2是21-12-2014。DateTime::Diff使用这两个日期的结果是0(我想是1,而不是零)我是不是漏掉了什么不好的东西,或者DateTime::Diff像我上面解释的那样计算日期差异?这是我正在使用的代码(我想以天为单位显示日期差异):$currentDay=newDateTime();$listDay=newDateTime($results["date"]);//frommysqldatabase(outputislike21-12-2014$inter

php - date_parse_from_format 到 unix 时间戳

我对date_parse_from_format()方法有疑问:$parsed=date_parse_from_format("YdMH:iT",'201228Nov21:00CET');Returnsassociativearraywithdetailedinfoaboutgivendate.这将返回一个包含一些日期信息的数组。但是有什么方法可以将它转换为unix时间戳吗? 最佳答案 约翰,下面是如何在您的场景中实现mktime的具体示例:$parsed=date_parse_from_format("YdMH:iT",'2012

php - 错误的月份(二月)- DateTime::createFromFormat

这个问题在这里已经有了答案:PHPDateTime::createFromFormatbehavoiur(2个答案)关闭去年。从字符串进行的日期转换返回第二个月(二月)的错误值:$dtformat='Y-m-01';$curDate=DateTime::createFromFormat('Y-m','1996-02');print_r($curDate);$dt=$curDate->format($dtformat);echo$dt."\n";它返回“1996-03-01”而不是“1996-02-01”。这是$currDate数组:DateTimeObject([date]=>1996

php - 单元测试包含 DateTime ("now"的函数)

我有一个类似这样的函数:publicfunctiongetSomeInfo($id){$date_start=newDateTime();$day_of_week=$date_start->format("N");$date_start=$date_start->sub(newDateInterval("P".$day_of_week."D"));$date_end=new$date_start;$date_end=$date_end->add(newDateInterval("P5D"));$date_start=$date_start->format("Y-m-d");$date_