+ Reply to Thread
Results 1 to 3 of 3

Thread: Format String

  1. #1
    Join Date
    Sun Apr 23 15:04:00 PDT 2006
    Location
    Karachi
    Age
    33
    Posts
    29

    Default Format String

    Hi,

    I want to format current time of the system to following format...

    Code:
    2006-11-27 12:59:00
    In VB6, I could do this with
    Code:
    Dim ss As String
    ss = Format( "YYYY-MM-DD HH:MM:SS", Now() )
    I read somewhere that following fuction do the same job, but its not working
    Code:
    string ss = String.Format("YYYY-MM-DD HH:MM:SS", DateTime.Now);
    It just returns "YYYY-MM-DD HH:MM:SS"

    any suggestions?

  2. #2
    Join Date
    Sat Jun 30 20:08:31 PDT 2007
    Posts
    3

    Default

    string s = DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss");

    Note: even the string in quotes is case-sensitive, so if you changed yyyy into YYYY it would stop working properly.

  3. #3
    Join Date
    Sun Apr 23 15:04:00 PDT 2006
    Location
    Karachi
    Age
    33
    Posts
    29

    Default

    Thanks al000t

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts