Home > other >  Change datetime picker output format
Change datetime picker output format

Time:06-13

How to change datetime picker output format for a specific format? I need change the format of the following selecteddate variable to "dd/M/yyyy" without converting to String and converting back to Datetime using DataTimeParse. Is there any method to change DateTime picker default picking format to "dd/M/yyyy" to instead of "MM/dd/yyyy". I've tried with picker properties->Custom Format but it doesn't work.

DateTime selecteddate = dateTimePicker1.Value.Date;

CodePudding user response:

You can set a custom format in 2 parameters like so:

    protected override void onl oad(EventArgs e)
    {
        dateTimePicker.Format = DateTimePickerFormat.Custom;
        dateTimePicker.CustomFormat = "MM/dd/yyyy";

        base.OnLoad(e);
    }
  • Related