草庐IT

from_date

全部标签

即使在设置 date_default_timezone_set 之后,PHPExcel 也会得到错误的时区

我正在使用http://phpexcel.codeplex.com在我的一个项目中,我遇到了一个问题。我想在单元格中写入time()值,我正在这样做:functionwriteTimeLine($objActiveSheet,&$lineNumber,$timeStart,$timeEnd,$duration,$category,$client,$date,$comment){$objActiveSheet->setCellValue('A'.$lineNumber,PHPExcel_Shared_Date::PHPToExcel($timeStart));$objActiveShee

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 : Best way to call an object method from another object ?

我正在寻找从另一个类调用类方法的最佳方法,而不必使用Global来获取类实例,因为我现在明白“全局是邪恶的”!下面是一些代码来解释它:classAssets{public$assets=array();publicfunctionadd($asset){$this->assets[]=$asset;}}现在我想在这里调用Assets/call方法..$assets=newAssets;classForm{publicfunction__construct(){global$assets;$assets->add('Form');}}在这种情况下使用Global是不是很糟糕?如果是这样,

php - 这是 PHP date() 错误,还是我的代码有问题?

我有两个箭头图像,一个向后递增月份,一个通过href向前递增。if(ISSET($_GET["month"])){$month_index=$_GET["month"];}else{$month_index=0;}$month=strtotime("+".$month_index."month");?>...>LogbookCalendarfor>问题是,当2015年2月出现时,date()返回“2015年3月”——因此$month_index=6和$month_index=7都是三月。我在http://writecodeonline.com/php/上运行了这段代码:date_def

php - openssl_pkey_export 和 "cannot get key from parameter 1"

我需要在我的php项目中使用openssl,所以我使用openssl创建了一个测试php页面。但是,我不断收到这些错误,我不确定为什么。openssl已启用。Warning:openssl_pkey_export()[function.openssl-pkey-export]:cannotgetkeyfromparameter1inC:\wamp\www\opensslsample\index.phponline18Warning:openssl_pkey_get_details()expectsparameter1toberesource,booleangiveninC:\wamp\

php - Yii 框架 : Using data from related Active Record models for searching

Yii1.1applicationdevelopmentCookbook解释了一种使用来自相关ActiveRecord模型的数据来搜索相关模型的方法。此方法在第193和194页中进行了说明。我已尝试将此方法集成到我的应用程序中,但它不起作用。谁能解释一下这个功能在Yii框架版本1.1.8中是否仍然可用在这个位置,我还可以找到用于从相关事件记录模型中搜索数据的注释。但它也不起作用。http://www.yiiframework.com/doc/api/1.1/CDbCriteria我有订单表和用户表订单表和用户表是一对多的关系。用户有很多订单,订单只有一个用户。因此,我正在编辑CDbCr

Php Date 函数在实时服务器中不起作用

我正在使用以下日期函数在本地主机中使用php显示当前日期和时间并将输出显示为2013-06-2414:45:13但是当我在实时服务器中运行上面的php代码时,它显示输出为2013-06-2406:47:28。所以,任何人都知道如何在实时服务器中以24小时格式显示日期和时间。 最佳答案 这是一个时区问题。检查date_default_timezone_get();使用date_default_timezone_set('YOUR_TIMEZONE');您可以设置时区。 关于PhpDate函

php - 如何删除 https ://from URL and insert http://instead of it in string in PHP?

首先,我需要检查URL字符串,如果URL的协议(protocol)是https,那么我需要替换PHP中的http。所以这个php函数的输入和输出必须是这样的:Input->https://example.com/example/https.phpOutput->http://example.com/example/https.phpInput->http://example.com/example/https.phpOutput->http://example.com/example/https.php 最佳答案 这将确保它位于字符

php - 在 Date() 上加一星期

如何将1周添加到具有单独日期变量的日期函数。日期需要分开,以便我可以将其插入到另一个表格中。如果我不能将它作为单独的变量来做,我可以在之后将它们分开吗?所以:$year=date("Y");$month=date("m");$day=date("d");echo'CurrentDate'.$year.'.'.$month.'.'.$day;echo'Date1WeekintheFuture'; 最佳答案 使用strtotime:echo"Date1WeekintheFuture".date('Y.m.d',strtotime('+1

php - 最简单的问题: extract values from array

这是一个例子:Array([0]=>Array([title]=>Title_1[checkout]=>1[no_gateway]=>0)[1]=>Array([title]=>Title_2[checkout]=>1[no_gateway]=>1)[2]=>Array([title]=>Title_3[checkout]=>0[no_gateway]=>0)[3]=>Array([title]=>Title_4[checkout]=>1[no_gateway]=>1)[4]=>Array([title]=>Title_5[checkout]=>0[no_gateway]=>0)[5]