如何在POSIXct中获得一天的开始(How to get the beginning of the day in POSIXct)
我的一天开始于
2016-03-02 00:00:00
。 不是2016-03-02 00:00:01
我如何在当地时间在
POSIXct
中获得一天的开始?我的困惑可能来自于R将此视为2016-03-01的结束日期的事实? 鉴于R使用ISO 8601?
例如,如果我尝试使用Sys.Date()来查找一天的开始:
as.POSIXct(Sys.Date(), tz = "CET") "2016-03-01 01:00:00 CET"
哪个不正确 - 但还有其他方法吗?
我知道我可以用简单的方式破解我的出路
as.POSIXct(paste(Sys.Date(), "00:00:00", sep = " "), tz = "CET")
但是必须有更正确的方法来做到这一点? 基础R优先。
My day starts at
2016-03-02 00:00:00
. Not2016-03-02 00:00:01
.How do I get the beginning of the day in
POSIXct
in local time?My confusing probably comes from the fact that R sees this as the end-date of 2016-03-01? Given that R uses an ISO 8601?
For example if I try to find the beginning of the day using Sys.Date():
as.POSIXct(Sys.Date(), tz = "CET") "2016-03-01 01:00:00 CET"
Which is not correct - but are there other ways?
I know I can hack my way out using a simple
as.POSIXct(paste(Sys.Date(), "00:00:00", sep = " "), tz = "CET")
But there has to be a more correct way to do this? Base R preferred.
原文:https://stackoverflow.com/questions/35720154
最满意答案
$ .ajax方法的默认contentType是
'application/x-www-form-urlencoded'
如果您想发送JSON,则必须指定您正在发送JSON,否则模型活页夹将无法正常工作:
$.ajax({ type: 'post', url: "@Url.Action("SaveTireRunModel", "Events")", data: tirerun, contentType: 'application/json', success: function(result) { if (!result.success) { alert(result.error); } else {} } });
您可能还需要使用以下
data: JSON.stringify(tirerun)
对数据进行“data: JSON.stringify(tirerun)
”:data: JSON.stringify(tirerun)
The default contentType for the $.ajax method is
'application/x-www-form-urlencoded'
If you want to send JSON you have to specify that your are sending JSON otherwise the Model Binder won't work correctly:
$.ajax({ type: 'post', url: "@Url.Action("SaveTireRunModel", "Events")", data: tirerun, contentType: 'application/json', success: function(result) { if (!result.success) { alert(result.error); } else {} } });
You maybe also need to "stringify" the data with :
data: JSON.stringify(tirerun)
相关问答
更多-
如何用ASP.NET MVC ViewModels使用knockout.js?(How to use knockout.js with ASP.NET MVC ViewModels?)[2022-11-10]
我想我总结了你的所有问题,如果我错过了一些事情,请让我知道( 如果你可以总结所有的问题在一个地方将是很好 =)) 注意。 与ko.editable插件兼容 下载完整的代码 你如何使用html帮助器与knockout.js 这很容易 @Html.TextBoxFor(model => model.CourseId, new { data_bind = "value: CourseId" }) 哪里: value: CourseId表示您将input控件的CourseId属性与模型中的CourseId属性和脚 ... -
基本上,MVVM js框架(如knockoutjs)旨在用于单页应用程序,其中您有最少的服务器端逻辑,单个服务器处理程序或MVC控制器操作(如果您愿意),即提供某些HTML。 所有的应用程序逻辑都是用javascript编写的。 只有来自客户端的REST服务的AJAX调用,并且所有视图模型都位于客户端上。 服务器只会向客户端发送初始JSON模型,但与该模型的所有交互都将在客户端上进行。 因此,尽管您可以在Razor中实现大量逻辑,但这仍然可以保持服务器端的处理。 如果您想要一个完全在客户端实现的非常动态的应 ...
-
这是由于输入字段中的name属性,@ Html.TextBox的意图使用带有名称属性数据绑定的输入HTML标记和正确的索引。 对于HttpPost期间的List,应该像name =“Boards [RowIndex] .PropertyName”。 从“td”标记中删除data-bind =“text:FromNumber”。 注意:“表单提交”必须使用“名称”属性。 索引值应从零开始。
MVC 4和Knockout(MVC 4 and Knockout)[2023-01-22]
你使用knockout.mapping插件,但我没有看到你包括映射插件js文件。 您需要在淘汰的lib文件之后包含它: https : //github.com/SteveSanderson/knockout.mapping/tree/master/build/output 。 此外,您的匿名函数永远不会运行。 要立即调用它,你需要用括号结束它,如下所示: (function () { var model = '@Html.Raw(Json.Encode(Model))'; var v ...$ .ajax方法的默认contentType是'application/x-www-form-urlencoded' 如果您想发送JSON,则必须指定您正在发送JSON,否则模型活页夹将无法正常工作: $.ajax({ type: 'post', url: "@Url.Action("SaveTireRunModel", "Events")", data: tirerun, contentType: 'application/json', ...Knockout asyncCommand / Ajax MVC ActionResults(Knockout asyncCommand / Ajax MVC ActionResults)[2022-03-10]
我的解决方案是改变ActionResult以将值返回给AJAX。 The solution for me was to alter the ActionResult to return a value to AJAX.如何在mvc中从AjaxForm调用淘汰模型的成功回调函数(How to call success callback function of knockout model from AjaxForm in mvc)[2023-02-12]
您应该执行以下操作: var viewModel = new LoginViewModel(); ko.applyBindings(viewModel); 然后你可以使用: (new AjaxOptions() { HttpMethod = "Post", OnSuccess = "viewModel.success") 您可以在此处看到,您需要创建视图模型的对象,然后调用该对象的success方法。 我还建议只使用jquery进行ajax调用,而不是在mvc中使用ajax。 You should do ...有很多方法可以实现这一点,但从根本上说,您通常使用JSON调用在前端和后端之间传递数据 ,通常是JSON格式。 将knockout.js observablearray对象传递给MVC Controller Action? 请注意回答调用..ko.toJSON(viewModel.AccessLevels)..将observable数组转换为JSON字符串,这将由该示例的MVC控制器在服务器端处理。 There are many ways to achieve that, but fundamentally ...我重构了你的jsFiddle。 希望你现在能更好地了解knockoutJS。 这不是你的整个页面/淘汰赛,但我想用这个片段可以解决你的问题。 标记:- ID:
Name:大规模MVC Web应用程序 - 使用Knockout和Razor(Large Scale MVC Web Application - Using Knockout and Razor)[2022-12-20]
我建议按照以下方式构建它: 为每个页面创建一个具有特定KnockOut ViewModel的不同JavaScript模块: var app = app || {}; app.pages = app.pages || {}; app.pages.userProfile = (function () { function UserProfileViewModel() { //view model specific code }; function init() { ...相关文章
更多- one day you will know
- 2004.08.15 0day 中文简介
- 《wordpress入门视频教程》(Beginning with wordpress)更新至第10集(插件安装和使用)[HDTV]
- 我是如何在15天开发出一个网站的
- 如何在 ListView 中显示 RadioButton???
- 如何在SOLR中嵌入自己的分词系统??
- 如何在SOLR中嵌入自己的分词系统
- 如何在ScriptTagProxy中带参数?
- 如何在jsp中显示数据库的图片
- 如何在javascript中写rails的helper代码
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)