Datatime value issue

Peter_1985 2,586 Reputation points


How to correct it below?

            tb_apply_date.Text = Datetime.Now.ToString();
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,762 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,480 questions
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 41,271 Reputation points Microsoft Vendor

    Hi @Peter_1985 , Welcome to Microsoft Q&A,

    In C#, the class for handling date and time is DateTime, not Datetime.

    tb_apply_date.Text = DateTime.Now.ToString();

    If you want to format the date and time in a specific way, you can use the ToString method with a format string. For example, if you want to display the date and time in the format "MM/dd/yyyy HH:mm:ss", you can do it like this:

    tb_apply_date.Text = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");

    Best Regards,


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful