草庐IT

listing_date

全部标签

php - Laravel:如何将参数传递到我的 View 并在 Form::text 和 Form::date 中显示它们?

我正在尝试制作用于编辑字段的View。其实我有两个问题:1)我使用我的Controller从我的数据库中获取我的数据,这是有效的,我尝试将它传递给我的View,但那是行不通的...2)我想在Form::text和Form::date中显示这些数据,这不起作用...我的Controller中有什么:publicfunctionedit($id){$data=DB::connection('my-db')->table('my-table')->where('id','=',$id)->select('field1','field2')->first();returnview('my-vi

php - "date_part(' 纪元 ', now() at time zone ' UTC ')"与 postgresql 中的 "now() at time zone ' UTC '"不同

我正在为数据库(PHP/Postgresql)编写一个基于Web的前端,我需要在其中存储各种日期/时间。时间应该始终以本地时间在客户端输入,并以本地时间显示。出于存储目的,我将所有日期/时间存储为整数(UNIX时间戳)并标准化为UTC。一个特定的字段有一个限制,不允许填写的时间戳是将来的,所以我用数据库约束试了一下...CONSTRAINTnot_futureCHECK(timestamp-300-300是为了在浏览器和服务器之间稍微不同步的情况下留出5分钟的余地。问题是,这个约束在提交当前时间时总是失败。我已经完成测试,并发现了以下内容。在PostgreSQL客户端中:SELECTn

PHP接口(interface): specify a parameter list,但不是参数类型

我创建了一个名为iMapper的界面。我希望我所有的映射器文件都实现该接口(interface)。但是每个mapper都会指定参数类型。例子:interfaceiMapper{publicfunctioninsert($obj);publicfunctionupdate($obj);publicfunctiondelete($obj);}classCarMapperimplementsiMapper{publicfunctioninsert(Car$obj){}publicfunctionupdate(Car$obj){}publicfunctiondelete(Car$obj){}}

php - date_create_from_format 接受无效日期作为输入

PHPdate_create_from_format函数接受不存在但格式有效的日期。我希望此函数的行为类似于date命令:niloct@HP-Mini:~$date--date="29/02/2011"+%sdate:invaliddate`29/02/2011'虽然这是在php中发生的事情:$tmp=date_create_from_format('d/m/YH:i:s',"29/02/201100:00:00",timezone_open('America/Sao_Paulo'));var_dump($tmp);/*output:object(DateTime)#28(3){["d

php - 解决 Zend Date DST 错误

我发现了abuginZend_DatewhensettingatimethatcrossestheDSTchange.下面是说明问题的代码:date_default_timezone_set('America/New_York');echo'';//DSTBEGINS'2012-03-1102:00:00'-"SpringForward"$a=newZend_Date('2012-03-1100:00:00','yyyy-MM-ddHH:mm:ss');$a->setTime('04:00:00','HH:mm:ss');echo$a->toString('yyyy-MM-ddHH:m

php - Zend 框架 2 : Set options as "selected" in select list

我正在尝试将第二个产品设置为在列表中选中,但下面的代码不起作用。任何的想法。谢谢$this->add(array('type'=>'Zend\Form\Element\Select','name'=>'manufacturer','options'=>array('label'=>'Manufacturername','value_options'=>$this->getManufacturer(),'empty_option'=>'---selectmanufacturer---',),'attributes'=>array('value'=>2,'selected'=>true,)

php - 拉维尔 5 : How to retrieve records according to date?

我有一个名为entries的表,它的created_at被定义为DATE类型。例如,如何获取3月15日的记录?我尝试过的$post=Entry::where(\DB::raw('DATE(created_at)'),'=',date('2015-03-15'))->get()->toJSON();但它返回空结果。迁移Schema::create('entries',function(Blueprint$table){$table->increments('id');$table->integer('intern_id');$table->integer('company_id');$t

php - PHP date_create() 上的 Twig 异常

我想根据她的生日计算一个选民的年龄,在我的实体中,我创建了一个这样的函数//voters.phppublicfunctiongetAge(){$birthday=$this->birthday;$age=date_diff(date_create($birthday),date_create('today'))->y;return$age;}我像这样在Twig中渲染它{{entity.getAge()}}但是显示如下错误:"Anexceptionhasbeenthrownduringtherenderingofatemplate("Warning:date_create()expect

php - while & list & each 组合在 PHP 上比 array_walk 和 foreach 快得多怎么可能?

我得到了这段代码:&$value)$function($value,$key,$userData);}//Testfunction3functionarray_walk_foreach2(&$array,$function,$userData=null){foreach($arrayas$key=>$value)$function($array[$key],$key,$userData);}functionsome_function(&$value,$key,$userData){$value="$key=>$userData";}functiontest($function,$cou

php - PHP函数date()的反义词是什么?

PHP中是否有任何函数可以获取日期并将其转换为时间戳,或者可以简单地获取一种格式的日期并将其更改为另一种格式?我有一组格式为“md”的日期,我想将其更改为“l,Fd,Y”。我还需要它和其他格式的日期,所以我需要一个函数,让我给它一个日期、输入格式和输出格式。 最佳答案 试试strtotime(http://www.php.net/strtotime) 关于php-PHP函数date()的反义词是什么?,我们在StackOverflow上找到一个类似的问题: h