包含毫秒的日期文字 [英] Date Literals That Include Milliseconds

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

问题描述

我有一个控件使用日期和时间,包括毫秒。我想

能够在* .aspx页面中输入此信息作为属性。

因为所有属性都在* .aspx页面中作为字符串输入,所以我需要一个

可识别的日期/时间字符串,其中包括日期和时间,包括

毫秒。有人可以告诉我这样做的最佳格式吗?谢谢。

(注意:日期/时间数据来自SQL

服务器数据库的数据绑定字段。)

-

Nathan Sokalski
nj ******** @ hotmail.com
http://www.nathansokalski.com/

解决方案

Nathan,


因为主要有很多进程忙,所以windows运行

系统可能不那么准确,你可以实时获得

毫秒。


但是datetime.millisecond给出的东西回到了什么

最多,但这不是文字,所以只需将

&添加到toString中。可能是最好的。


Cor


" Nathan Sokalski" < nj ******** @ hotmail.comschreef在bericht

新闻:eY ************** @ TK2MSFTNGP05.phx.gbl .. 。


>我有一个控件使用日期和时间,包括毫秒。我希望能够在* .aspx页面中将此信息作为属性输入。
因为所有属性都是在* .aspx页面中作为字符串输入的,所以我需要一个可识别的日期/ time字符串,包括日期和时间,包括
毫秒。有人可以告诉我这样做的最佳格式吗?谢谢。
(注意:日期/时间数据来自SQL
服务器数据库的数据绑定字段。)

-

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


" Nathan Sokalski" < nj ******** @ hotmail.comwrote in message

news:eY ************** @ TK2MSFTNGP05.phx.gbl .. 。


>我有一个控件使用日期和时间,包括毫秒。我希望能够在* .aspx页面中将此信息作为属性输入。
因为所有属性都是在* .aspx页面中作为字符串输入的,所以我需要一个可识别的日期/ time字符串,包括日期和时间,包括
毫秒。有人可以告诉我这样做的最佳格式吗?谢谢。
(注意:日期/时间数据来自SQL
服务器数据库的数据绑定字段。)



DateTime dtmDateTime = <然而你得到你的日期时间变量> ;;

string strDateTime = dtmDateTime.ToString(" dd MMM yyyy HH:mm:ss:fff");

-

Mark Rae

ASP.NET MVP
http://www.markrae.net


你让我困惑;您给出的示例是在代码隐藏中,我是
寻找可以分配给日期时间属性的字符串

包括毫秒。例如:


< cc1:TimePicker id =" timepkr" RUNAT = QUOT;服务器" SelectedTime =" datetime string

with milliseconds">


SelectedTime是DateTime类型的属性,所以我需要知道如何格式化

我分配给它的字符串。你给出的例子分配了一个字符串,你没有向我显示一个DateTime并将一个DateTime分配给一个字符串。你没有

告诉我我正在寻找的信息:当你将它分配给DateTime时,字符串是什么格式

?谢谢。

-

Nathan Sokalski
nj * *******@hotmail.com
http:// www.nathansokalski.com/

" Mark Rae [MVP]" < ma ** @ markNOSPAMrae.netwrote in message

news:en ************* @ TK2MSFTNGP06.phx.gbl ...


" Nathan Sokalski" < nj ******** @ hotmail.comwrote in message

news:eY ************** @ TK2MSFTNGP05.phx.gbl .. 。


>>我有一个控件使用日期和时间,包括毫秒。我希望能够在* .aspx页面中将此信息作为属性输入。
因为所有属性都是在* .aspx页面中作为字符串输入的,所以我需要一个可识别的日期/ time字符串,包括日期和时间,包括
毫秒。有人可以告诉我这样做的最佳格式吗?谢谢。
(注意:日期/时间数据来自SQL
服务器数据库的数据绑定字段。)



DateTime dtmDateTime = <然而你得到你的日期时间变量> ;;

string strDateTime = dtmDateTime.ToString(" dd MMM yyyy HH:mm:ss:fff");


-

Mark Rae

ASP.NET MVP
http://www.markrae.net



I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

解决方案

Nathan,

Because there are so many processes bussy mostly, is the windows operating
system probably not that accurate that you can get the real time in
milliseconds.

However the datetime.millisecond gives something back what reaches that the
most, but that is not in a literal, so just appending the toString with the
& will probably be the best.

Cor

"Nathan Sokalski" <nj********@hotmail.comschreef in bericht
news:eY**************@TK2MSFTNGP05.phx.gbl...

>I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eY**************@TK2MSFTNGP05.phx.gbl...

>I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)

DateTime dtmDateTime = <however you get your datetime variable>;
string strDateTime = dtmDateTime.ToString("dd MMM yyyy HH:mm:ss:fff");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


You have me confused; the examples you give are in the codebehind, I am
looking for a string that can be assigned to a datetime attribute that
includes milliseconds. For example:

<cc1:TimePicker id="timepkr" runat="server" SelectedTime="datetime string
with milliseconds">

SelectedTime is a property of type DateTime, so I need to know how to format
the string I assign to it. The examples you gave assign a String that you
didn''t show me to a DateTime and assign a DateTime to a String. You did not
tell me the piece of information I am looking for: What format is the string
in when you assign it to the DateTime? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:en*************@TK2MSFTNGP06.phx.gbl...

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eY**************@TK2MSFTNGP05.phx.gbl...

>>I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)


DateTime dtmDateTime = <however you get your datetime variable>;
string strDateTime = dtmDateTime.ToString("dd MMM yyyy HH:mm:ss:fff");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net



这篇关于包含毫秒的日期文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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