草庐IT

local_date_time

全部标签

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 - 在运行时为 Lumen 的 .env 文件中定义的 APP_LOCALE 设置值

我最近开始学习Lumen微框架,我需要在运行时更改我的.env文件中定义的APP_LOCALE键的值。我的目标是在运行时切换语言以打印我的语言文件中定义的特定字符串的不同翻译。在Lumen文档中是这样写的:Tosetconfigurationvaluesatruntime,passanarraytotheconfighelper所以我在测试Controller中尝试了休闲:useIlluminate\Support\Facades\App;useLaravel\Lumen\Routing\ControllerasBaseController;classControllerextends

php - <b> fatal error </b> : Uncaught exception 'Exception' with message 'Failed to connect to api.twitter.com port 443: Connection timed out'

我正在开发一个Codeigniter项目,在该项目中我使用twitterapi库来获取twitter数据。在我更改服务器之前它工作得很好,但是在更改服务器之后它产生了以下错误。我不知道问题所在。Fatalerror:Uncaughtexception'Exception'withmessage'Failedtoconnecttoapi.twitter.comport443:Connectiontimedout'in/my/project/path/myProject/application/ws/libraries/TwitterAPIExchange.php:297Stacktrac

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 - PHP函数date()的反义词是什么?

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

php - 在 PHP 和 javascript 中使用 time() 和 setTime() 函数

我想要一个javascript日期对象,其时间根据网络服务器设置。vardate=newDate();date.setTime();alert(date.toString());//displaysthedateandtimeaccordingtothetimezonesetontheclient'scomputer上面的代码靠谱吗?非常感谢大家。 最佳答案 我认为不是。自Javascript'ssetTime()使用毫秒和PHP'stime()使用秒。您需要添加一些东西才能使其正常工作;)我会让您知道是什么。

PHP date_sun_info 错误时间

我正在尝试使用PHP的date_sun_info函数来获取有关全天太阳某些位置的时间的信息:目前我正在使用类似于documentation中的代码.$sun_info=date_sun_info(strtotime('today'),40.42,74.0);foreach($sun_infoas$key=>$val){echo"$key:".date("H:i:s",$val)."";}输出是:sunrise:20:50:20sunset:07:45:03transit:02:17:41civil_twilight_begin:20:22:45civil_twilight_end:08

php - 默认 date() 应该提前 3 个月

我的服务器有很多应用程序实例。我遇到了一个问题,我的一个应用程序实例需要用future的日期进行测试。即我想测试2013年运行的应用程序。如果我更改系统日期,那么它将正常工作,但其他实例也会受到影响。我只想要一个实例的future日期,其余的应该按原样工作。即如果我使用date('Y-m-d');它应该跳转3个月并显示future的日期。而且我不想将秒数添加到默认日期,因为这可能是我的应用程序中的一个巨大变化。 最佳答案 这就是您以可测试的方式编写应用程序的原因。不好:functiondoSomething(){$date=date

php - 有人能解释一下 date ("YW", strtotime ("2016-01-02"));返回 “201653” ?

date("YW",strtotime("2016-01-02"));returns“201653”年还可以周是从2015年开始的 最佳答案 PHP是ISO-8601符合日期:Thepurposeofthisstandardistoprovideanunambiguousandwell-definedmethodofrepresentingdatesandtimes,soastoavoidmisinterpretationofnumericrepresentationsofdatesandtimes,particularlywhen

php - 拉维尔 5.2 :How to display time like this?

我正在使用Laravel5.2,我想这样显示文章的创建时间:created_atdisplayingin1daytoday2-10days(2-10)daysago>10daysshowcreationdatedirectly怎么做?提前致谢!编辑:Controller:publicfunctionshow($id){$article=Article::findOrFail($id);returnview('show',compact('article'));}查看:{{$article->title}}{{$article->content}}{{$article->created_