ASP.Net [2.0] - 将日期转换为新格式...... [英] ASP.Net [2.0] - Converting a date to a new format...

查看:54
本文介绍了ASP.Net [2.0] - 将日期转换为新格式......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


好​​的 - 我来自1.1背景 - 之前我从来没有遇到过任何问题这个:


Response.Write(会话(" MyDate")。)ToString(" dd / MM / yyyy"))


所以,我可能会举个例子:


21/05/2006


好​​的 - 只是尝试在.net 2.0中完全相同的东西我没有结束

问题..


我的日期来自我的SQL Server数据库,它存储为日期时间。


这个值被加入我的班级,它将值存储为DATE

并通过属性作为DATE返回值。

我尝试的东西似乎无关紧要我只能将整个

值(21/05/2006 19:59:00)抛弃或让自己变得更好错误信息...


说这开始给我红色屁股将是一个轻微的承诺......因此我承认失败并要求在这个

组中有人更聪明地帮助我..


我事先感谢你的.Net Grand-Masta'...


Rob:o)

Hi all,

Ok - I''ve come from a 1.1 background - and previously I''ve never had any
problem with doing this:

Response.Write (Session("MyDate").ToString("dd/MM/yyyy"))

So, I might get this for example:

21/05/2006

Ok - just tried exactly the same thing in .net 2.0 and I''m having no end of
problems..

My date comes from my SQL Server database which is stored as a datetime.

This value gets plonked into my class which both stores the value as a DATE
and returns the value via a property as a DATE.

It doesn''t seem to matter what I try I can either only dump out the whole
value (21/05/2006 19:59:00) or get myself a nice error message...

To say that this was beginning to give me the "red arse" would be an
understatement...I therefore admit defeat and ask that someone wiser in this
group assist me..

I thank you in advance my .Net Grand-Masta''s...

Rob :o)

推荐答案

" Rob Meade" < te ********************* @ edaem.bbor>'疯狂

想法于2006年5月21日在Sun发布19:00:46 GMT

带有以下水果:
"Rob Meade" <te*********************@edaem.bbor>''s wild
thoughts were released on Sun, 21 May 2006 19:00:46 GMT
bearing the following fruit:
大家好,

好的 - 我来自1.1背景 - 以前我从来没有遇到过这样的问题:

Response.Write(Session(" MyDate")。)ToString(" dd / MM / yyyy))

所以,我可能会举例说:

21/05/2006

好的 - 试过完全一样的东西在.net 2.0中我没有结束
问题..

我的日期来自我的SQL Server数据库,它存储为日期时间。
这个值被加入到我的类中,它将值存储为DATE
并通过属性作为DATE返回值。

我尝试的似乎并不重要我可以只丢掉整个
值(21/05/2006 19:59:00)或者给自己一个很好的错误信息......

要说t帽子这开始给我红屁股会是轻描淡写的......因此我承认失败并要求在这个
小组中有人更聪明地帮助我..

我提前感谢你的.Net Grand-Masta是的......

Rob:o)
Hi all,

Ok - I''ve come from a 1.1 background - and previously I''ve never had any
problem with doing this:

Response.Write (Session("MyDate").ToString("dd/MM/yyyy"))

So, I might get this for example:

21/05/2006

Ok - just tried exactly the same thing in .net 2.0 and I''m having no end of
problems..

My date comes from my SQL Server database which is stored as a datetime.

This value gets plonked into my class which both stores the value as a DATE
and returns the value via a property as a DATE.

It doesn''t seem to matter what I try I can either only dump out the whole
value (21/05/2006 19:59:00) or get myself a nice error message...

To say that this was beginning to give me the "red arse" would be an
understatement...I therefore admit defeat and ask that someone wiser in this
group assist me..

I thank you in advance my .Net Grand-Masta''s...

Rob :o)




我不清楚问题是什么,你似乎在说

你希望日期变量像格式化的字符串一样工作,并且

表示不会发生。


有什么关系数据变量如何保存日期?

你不能以你想要的格式显示日期

无论如何?


Jan Hyde(VB MVP)


-

现金损失与僻静的故事之间有什么区别

宗教社区?

一个是金钱故事,另一个是修道院


(Lars Hanson)



I''m not clear what the problem is, you appear to be saying
you want date variables to act like formatted strings and
that ain''t gonna happen.

What does it matter how the data variable holds the date?
Aren''t you displaying the date in the format you desire
anyway?

Jan Hyde (VB MVP)

--
What''s the difference between a tale of lost cash and a secluded
religious community?
One is a money story, and the other is a monastery

(Lars Hanson)


" Jan Hyde"写道......
"Jan Hyde" wrote ...
我不清楚问题是什么,你似乎在说
你希望日期变量像格式化的字符串一样工作和
那不会发生。


嗨Jan,谢谢你的回复。


很明显,我并没有很好地解释自己......道歉。

数据变量如何保存日期有什么关系?
你不是以你想要的格式显示日期吗?
I''m not clear what the problem is, you appear to be saying
you want date variables to act like formatted strings and
that ain''t gonna happen.
Hi Jan, thank you for your reply.

Clearly I didn''t explain myself very well...my apologies.
What does it matter how the data variable holds the date?
Aren''t you displaying the date in the format you desire anyway?




我将日期存储在数据库中,我的班级作为日期,它还有

时间等...


我是什么希望能够在我的网页上这样说:


"上次更新时间:22/05/2006 11:46"


我不想要的是:


"上次更新日期:05/22/2006 11:46:01 AM"或其他任何其他感觉添加

等:)


以前我能做的是:


Response.Write(myDate.ToString(" dd / MM / yyyy HH:mm")


我就是这样:

22 / 05/2006 11:46


我现在无法在.net 2.0中执行此操作 - ToString函数没有给出

格式化的东西相反,我得到了一个索引?

有点奇怪的是我可以输入..


..ToString.ToString( dd / MM / yyyy) - 不是说它有用,但我觉得很奇怪

我可以把串起来???


是否有这个更清楚吗?


问候


Rob


PS:你用什么来在顶部配置回复?

ie,



I have the date stored in the database and my class as a date, it also has
the time etc...

What I want to be able to do on my web page is say this:

"Last updated: 22/05/2006 11:46"

what I dont want is this:

"Last updated: 05/22/2006 11:46:01 AM" or whatever else it feel like adding
etc :)

What I used to be able to do was this:

Response.Write (myDate.ToString("dd/MM/yyyy HH:mm")

and I get exactly that:
22/05/2006 11:46

I am unable to do this now in .net 2.0 - the ToString function does not give
you the format stuff in the brackets, instead I get an "index" instead?
whats a bit weird is that I can type..

..ToString.ToString("dd/MM/yyyy") - not that it worked, but I thought it odd
I could tostring a tostring??!

Is any of this any clearer?

Regards

Rob

PS: What do you use to configure that reply at the top?
ie,


该死的控制+输入键盘捷径!!!

我的意思是 - 你如何使用自己的
消息 - 我之前见过但却从未找到过这样做的方式

it ..
Damn that control+enter keyboard short cut!!!

What I meant was - how do you automate this kind stuff with your own
message - I''ve seen it before but never been able to find a way of doing
it..
" ; Rob Meade 2006年5月21日星期日19:00:46 GM发布了狂野的想法,其中包含以下成果:
"Rob Meade" wild thoughts were released on Sun, 21 May 2006 19:00:46 GMT
bearing the following fruit:




呵呵



hehe


这篇关于ASP.Net [2.0] - 将日期转换为新格式......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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