Tom,
I don't understand what you are trying to do. The representation of a
DateTime structure in .NET is just that, an instance of the DateTime
structure.
If you want to get that date in a string that is formatted that way,
take the string that I posted, and then pass it into the ToString method,
like this:
// Get the current date/time in the string format we desire.
string pstrFormattedDateTime = DateTime.Now.ToString("M/D/yyyy h:m:s tt");
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com
"Tom" <ke*****@yahoo.com> wrote in message
news:06****************************@phx.gbl...
Hi,
I replaced DateTime.Now with DateTime.Now.ToString(). But,
the date is same as before.
Could you teach me how to get the M/D/yyyy h:m:s tt format
from that date string?
Thanks for help
Tom
-----Original Message-----
Tom,
When using the ToString method on the DateTime
structure, you can usethe following format string to get the format that you
wish:
M/D/yyyy h:m:s tt
If you want to have a leading zero for any of the
arguments (month, day,hour, minute, second), then double up the format
character for that section.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)
paldino=at=exisconsulting<dot>com
"Tom Pair" <ke*****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hi,
I use DateTime.Now to display the current date and time. For instance, it's default format is 2003-10-29 21:23:36.
How can I change the format as follows?
10/29/2003 9:23:36 PM
MM/DD/YY HH/MM/SS AM/PM
Thanks for help
Tom
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
.