草庐IT

date_found

全部标签

javascript - 从 Date 我只想在 javascript/angularjs 中减去 1 天

在newDate()的帮助下,我如何实现这一目标。我的代码:vartemp=newDate("October13,201422:34:17");console.log(newDate(temp-1));要求:before:Aug4,201411:59pm(EDT)after:Aug3,201411:59pm(EDT) 最佳答案 您需要指定要减去的时间。目前它是1,但是1是什么?因此,尝试使用getDate()获取日期,然后从中减去,然后使用setDate()设置日期。例如vartemp=newDate("October13,2014

javascript date getYear() 在 IE 和 Firefox 之间返回不同的结果,如何处理这个问题?

显然javascript日期对象的方法getYear()在IE8和Firefox3.6之间返回不同的结果(我的机器上有这两个,不确定其他浏览器或版本)Dated=newDate();alert(d.getYear());FF3.6==>111(yearsince1900?iguess)IE8===>2011我一直只在Firefox上进行测试,现在我调整getYear()返回值的Javascript代码现在由于我的编码而给了我3911。varmodified=d.getYear()+1900在Firefox上它返回2011。但是如果我在IE8上应用这种方法,它返回3911。我可以添加逻辑

javascript - Angularjs Bootstrap 日期选择器 : Select multiple dates

我正在尝试使用AngularUI表带日期选择器。如何从日期选择器中选择多个日期并将值作为数组返回。http://mgcrea.github.io/angular-strap/#/datepicker 最佳答案 您可以使用gm.datepickerMultiSelect指令,它环绕着ui-bootstrapdatepicker指令,添加多选功能。varmyApp=angular.module('myApp',['gm.datepickerMultiSelect']);functionAppCtrl($scope){$scope.act

javascript - Uncaught Error : [$injector:cdep] Circular dependency found: $templateRequest <- $animate <- cfpLoadingBar <- $http <- $templateRequest <- $compile

我的AngularJS应用程序有问题我使用nuget从AngularJS1.3.0Beta升级到1.3.16,但出现以下错误:angular.js:4183UncaughtError:[$injector:cdep]Circulardependencyfound:$templateRequesthttp://errors.angularjs.org/1.3.16/$injector/cdep?p0=%24templateRequest%20%…oadingBar%20%3C-%20%24http%20%3C-%20%24templateRequest%20%3C-%20%24compi

javascript - 谷歌图表 : passing dates without using Date()?

总结我正在尝试在GoogleCharts中制作一个以日期为X轴的折线图。我已经对所有内容进行了排序,但它需要将日期传递为Date对象,即newDate(2005,3,13).有什么方法可以将其作为Unix时间戳或字符串传递吗?更多详情所以我有一堆用PHP编写的数据要用图表表示。我正在获取数据并将其排列成一个数组,其格式将在运行json_encode()时生成正确的JSON格式。,根据theGoogledatadocs:$graph_data=array('cols'=>array(array('id'=>'date','label'=>'Date','type'=>'datetime'

javascript - AngularJS 中 input[date] 和 Moment.js 的绑定(bind)

为了提出问题,我准备了一个简化的例子:......angular.module('dateInputExample',[]).controller('DateController',['$scope',function($scope){$scope.selectedMoment=moment();//...morecode...}]);基本上,我只需要在模型(moment.js的日期)和View(输入[日期]字段)之间进行绑定(bind)即可正常工作——当模型更新时,日期输入也会更新,反之亦然。显然,尝试上面的例子会给你带来模型不是Date类型的错误。这就是为什么我要问有经验的Angu

javascript - ng2-translate (404 not found) 我已经在 system.js 中添加了

我已将ng2-translate安装到我的项目中,但控制台错误一直显示404包和xhr错误。我已将ng2-translate添加到标准angular2quickstart附带的system.config.js,但仍显示404和xhr错误。它要么给我404错误,要么给出未定义错误的注释:/github:关于使用systemconfig.js的问题的线程https://github.com/ocombe/ng2-translate/issues/167varmap={'app':'app',//'dist','@angular':'node_modules/@angular','angul

javascript - 在 meteor 中使用 spacejam 时出现 "fetch is not found globally and no fetcher passed"

我正在编写单元测试来检查我的api。在我将我的gittest分支与我的dev分支合并之前,一切都很好,但后来我开始遇到这个错误:Apprunningat:http://localhost:4096/spacejam:meteorisreadyspacejam:spawningphantomjsphantomjs:Runningtestsathttp://localhost:4096/localusingtest-in-consolephantomjs:Error:fetchisnotfoundgloballyandnofetcherpassed,tofixpassafetchforyo

javascript - IE Date.parse 方法为 Date with Time 字符串返回 NaN

我们正在尝试用时间戳字符串解析日期,它在IE中爆炸但在FireFox中运行良好。代码如下警报(新日期(Date.parse("2010-01-31T12:00:00.233467-05:00")));有没有让它在IE浏览器中工作的想法?提前致谢。 最佳答案 如果您能以这种形式输入您的信息:YYYY/MM/DDThh:mm:ss它会起作用。例如:alert(newDate(Date.parse('2010-01-31T12:00:00.233467-05:00'.replace(/\-/ig,'/').split('.')[0])))

Javascript Date.toJSON 不获取时区偏移量

问题是我使用的代码是这样的:newDate().toJSON().slice(0,10)获取我的日期作为YYYY-MM-DD字符串,然后我在一些mysql查询和一些条件语句中像参数一样使用它。在一天结束时,我没有得到正确的日期,因为它还在前一天(我的时区偏移量是+2/3小时)。我没有注意到toJSON方法没有考虑您的时区偏移,所以我最终得到了这个hacky解决方案:vartoday=newDate();today.setHours(today.getHours()+(today.getTimezoneOffset()/-60));console.log(today.toJSON().s