草庐IT

Datetime

全部标签

javascript - 如何在给定的日期时间运行 javascript 函数

我只想在给定的日期/时间运行一些特定的javascript函数一次。例如,我在php中有一个日期时间变量,如下所示。$date="May7,201517:08:43";我有一些类似的功能functionsome_function(){..........}如何在给定的日期时间2015年5月7日17:08:43只运行一次此函数。我试过了,但它不能正常工作。vardate="";varmyDate=newDate();varcurrent_date=(myDate.getMonth()+1)+"/"+myDate.getDate()+"/"+myDate.getFullYear()+"/"

php - 处理 PHP DateTime 中格式正确但无效的日期

我正在尝试使用PHP的DateTime来验证日期,但DateTime会接受一些格式正确但无效的日期,例如2015-02-30,它将变成March2,2015,没有抛出异常。使用DateTime或其他方法处理此问题有什么建议吗?编辑:谢谢大家的帮助!我是通过捕获异常来处理错误的,但我没有意识到异常只是在错误时抛出,而不是警告,而且这种输入只会引发警告。 最佳答案 使用DateTime::getLastErrors()检查错误。格式正确但无效的日期:$date='2015-02-30';DateTime::createFromForma

php - 使用 diffForHumans() 方法的 now() 与日期时间与 "ago"的碳差异

根据手册:http://carbon.nesbot.com/docs/#api-humandiff获取一个agoWhencomparingavalueinthepasttodefaultnow但无论我做什么,我都无法获取ago返回$datetime->diffForHumans(Carbon::now())之前的结果,而returnCarbon::now()->diffForHumans($datetime);之后的结果,但是你可以清楚地看到我上面的两个代码片段比较了past($datetime)和现在的默认值(Carbon::now())所以我不明白为什么我不能得到以前?希望有人能帮

php - 在 PHP 中获取日期和数字工作日

我正在用PHP开发一个应用程序,我需要使用日期和工作日的数字表示。我试过以下方法:$today=date("Y-m-d");$number=date('N',strtotime($today));echo"Today:".$today."weekday:".$number."";$today=strtotime($today);$tomorrow=strtotime($today);$tomorrow=strtotime("+1day",$today);$number2=date('N',strtotime($tomorrow));echo"Tomorrow:".date('Y-m-d

php - 给定开始日期和持续时间,如何计算每月的天数?

试图找出一个小问题。我有一个开始日期和一个持续时间(以周为单位),需要计算持续时间内每月的工作天数。例如:开始日期:2011-02-07持续时间:10周我想取回以下内容:二月:16天三月:23天四月:11天任何帮助都会很棒。谢谢。 最佳答案 5.3之前的解决方案:$start=$current=strtotime('2011-02-07');$end=strtotime('+10weeks',$start);$months=array();while($current输出(codepad):Array([Feb]=>16[Mar]=

php 将时间戳转换为 xml 日期时间

在PHP中,如何转换像这样的mysql时间戳“1125443836”像这样的xml/date-time:2011-01-2502:10:32更新:mySQL中的列存储为int(10)。根据下面的示例,这是我在数据库中使用两个示例值进行的尝试。有什么不对,可能哈希或Unix日期存储在mySQL表中?$testSqlDateStamp="1125443836";echo"DateTest=".date('Y-m-dG:i:s',strtotime($testSqlDateStamp));$testSqlDateStamp="1125444107";echo"DateTest=".date(

php - 闰年的最后一天,第 53 周还是第 1 周?

我有一个脚本可以处理原始CSV数据并生成按一年中的一周分组的报告。看起来像这样://timezoneissettoEurope/London$date=newDateTime($raw['order_date']);//example:12/31/2012$key=$date->format('YW');//201201$array[$key][]=$raw['product_id'];在我尝试解析新年前夕生成的数据之前,一切正常,由于某种原因系统认为2012年12月31日是2012年的第1周。我不确定它是错误还是功能,但生成的报告肯定是错误的。传递此问题并按周对数据进行分组的正确方法

php - 将日期时间字段拆分为两个字段的表单

我想使用Symfony2.3将DateTime字段拆分为两个字段(日期和时间)。因此,我尝试调整找到的Symfony2.0解决方案here并对Symfony2.3进行了必要的更改。新类型:classMyDateTimeTypeextendsAbstractType{publicfunctionbuildForm(FormBuilderInterface$builder,array$options){$builder->add('date','date',array('label'=>'label.form.date','input'=>'datetime','widget'=>'sin

php - symfony 从 json 数据中保留日期时间

您好,我以JSON格式接收数据,在我的服务器站点上,我必须通过Doctrine存储它们。一切顺利,但当我收到日期时间格式数据时出现验证错误。我在Controller中对单独的操作测试了这个案例:publicfunctionindexAction($name){$em=$this->getDoctrine()->getManager();$test=newTest();$test->setName("Test");//$test->setStart(new\DateTime());$form=$this->createForm(newTestType(),$test);$store=ar

php - strtotime 在转换日期字符串时返回 false

将php5.4.34和Laravel4与apache2.2.22和Ubuntu一起使用。我尝试将字符串'2050-10-13'转换为日期,但它始终返回false。var_dump(strtotime('2050-10-13'));==>falsevar_dump(strtotime('13-10-2050'));==>falsevar_dump(strtotime('2050/10/13'));==>falsevar_dump(strtotime('13/10/2050'));==>false我之前尝试添加:date_default_timezone_set('Europe/Bruss