locked
datetime format RRS feed

  • Question

  • User1248258412 posted

    how to get datetime.now converted to string with this format DDMMYYHHMMSS

    My code as this Dim dt As DateTime = DateTime.Now

    Dim str As String = dt.ToString("DDMMYYHHMMSS")

    But the format is not I want, how to format it become DDMMYYHHMMSS ?

    dt value show #6/23/2016 11:05:24 AM#

    str value become DD06YY1106SS

    Thursday, June 23, 2016 3:07 AM

Answers

  • User1724605321 posted

    Hi aoshi_kh,

    You could try to use below format :

            Console.WriteLine(DateTime.Now.ToString("ddMMyyHHmmss"))
                              

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 23, 2016 5:31 AM

All replies

  • User1724605321 posted

    Hi aoshi_kh,

    You could try to use below format :

            Console.WriteLine(DateTime.Now.ToString("ddMMyyHHmmss"))
                              

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 23, 2016 5:31 AM
  • User1248258412 posted

    Hi Nan Yu, this work perfectly, thank you so much.

    Thursday, June 23, 2016 5:48 AM