GetDateTimeFormats()[110])

929 views
Skip to first unread message

ND

unread,
Jan 11, 2009, 6:50:55 AM1/11/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I need output timestamp as 2009-01-09 00:00:00 format, in 24 hour
format

I am forming the result with below row:

strcreatetimestamp = (((DateTime)(datarow.ItemArray
[13])).GetDateTimeFormats()[5] + ((DateTime)(datarow.ItemArray
[13])).GetDateTimeFormats()[110]) ;

but, with this I am getting Something like: 2009-01-09 02:00:00 AM

I guess the incorrect output could be because of culture settings en-
us to use GetDateTimeFormats)[] function, how can i determine which
culture is being used on the server. this is coded inside exe which
runs on a server.

please suggest any possible workaround at this stage without need to
modifying code and get the required output format.

Please correct me if any of above assumptions are incorrect

Thanks in advance.

Cerebrus

unread,
Jan 11, 2009, 8:59:49 AM1/11/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Since GetDateTimeFormats() outputs ALL possible supported formats into
an array, using it in your scenario seems like a terrible way to get
ONE string format ! Or maybe I haven't comprehended your scenario
correctly.

Going with my assumptions, I wouild simply use the ToString() method
of the DateTime instance to output the format I need :

Dim s As String = myDateTime.ToString("yyyy-MM-dd HH:mm:ss")

Harika medikonda

unread,
Jan 12, 2009, 4:17:50 AM1/12/09
to DotNetDe...@googlegroups.com
Hi,
 
 You can use
 
Dim curdte As DateTime
curdte = Now()
Response.Write("dd-MMM-yyyy : " & curdte.ToString("dd-MMM-yyyy"))
 
for more formats  refer to below link
 

ND

unread,
Jan 12, 2009, 6:43:41 AM1/12/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Cerebrus,
your suggestion is good. but scenerio is that the now code can't be
modified with my hands. I referred to

http://weblogs.asp.net/jlerman/pages/25420.aspx, while coding which
displays output as per my requirement.

where, 1. ((DateTime)(datarow.ItemArray[13])).GetDateTimeFormats()[5])
returns 2003-09-01
2. ((DateTime)(datarow.ItemArray[13])).GetDateTimeFormats()[110])
returns 0:00:00

the second case above is not working, it's returning me 00:00:00 AM.
Is this behaviour correct. I check the culture at my server as "en-
US".

any reason for above much appreciated. solution other than using
GetDateTimeFormats, will not help me at this moment.

Rgds,
ND
> > Thanks in advance.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages