mvc中的日期格式化问题 [英] date formating issue in mvc

查看:536
本文介绍了mvc中的日期格式化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ..

我有一个日期,给出当前日期,月份和5年以上,但是当我更改系统日期时,包含日期的列表会获得invaild ..





这里是我的javascipt代码 -



  var  param1 =  new  Date(); 
var param2 = param1.getDate()+ ' /' +(param1.getMonth()+ 1 )+ ' /' +(param1.getFullYear()+ 5 );







在我的控制器中 -

我得到一个清单,如果我改变系统日期时间格式,然后列表中的元素(日期时间)变得无效(显示:01/01/0001)。





有什么想法吗?

解决方案

您可以根据需要使用日期格式插件格式化日期。



jquery-dateFormat



 

.format.date(param1,'dd / MM / yyyy')


Hello

在c#Date时间完全取决于机器或服务器日期时间的文化信息,如果你改变你的日期时间格式,它会自动更改为什么会给出错误。

解决这个问题你可以用mm / dd / yyyy格式发送日期和它是sql server的唯一格式,您可以轻松将其输入数据库。





显示时请将其更改为dd / mm / yyyy或您的要求。

  var  param1 = 日期(); 
var param2 =(param1.getMonth()+ 1 )+ ' /' + param1.getDate()+ ' /' +(param1.getFullYear()+ 5 );









i希望你的问题能解决,如果没有请评论。


heyy..
I have a date ,that give the current day, month and 5+ year , but when I change the system date , the list that contains the date get invaild..


here is my javascipt code -

var param1 = new Date();
              var param2 = param1.getDate() + '/' + (param1.getMonth() + 1) + '/' + (param1.getFullYear() + 5);




IN my controller -
Iam getting a list ,If I change the system datetime format, then the element(datetime) in the list get invalid(display : 01/01/0001).


Any idea?

解决方案

You can use date format plugin for format the date according to your requirement.

jquery-dateFormat


.format.date(param1, 'dd/MM/yyyy')


Hello
in c# Datetime is totally dependent of culture information of machine or server datetime if you change your datetime format it automatically change thats why give error.
for solving this you can send date in mm/dd/yyyy format and it is unique format for sql server you can easy enter it on to the database.


when you display it please change it into dd/mm/yyyy or your requirement.

var param1 = new Date();
              var param2 = (param1.getMonth() + 1) + '/' +  param1.getDate() + '/' + (param1.getFullYear() + 5);





i hope your problem will solve if not please comment.


这篇关于mvc中的日期格式化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆