# Specifying the Date and Time

## Content



You can specify the time and date of a C1DateTimePicker control by setting the <span data-popup-content="This class is available in \u003ca href=\u0022/componentone/api/wpf/online-datetimeeditors/dotnet-api/C1.WPF.DateTimeEditors/C1.WPF.DateTimeEditors.C1DateTimePicker.DateTime.html\u0022\u003e.NET\u003c/a\u003e and \u003ca href=\u0022/componentone/api/wpf/online-datetimeeditors/dotnet-api/C1.WPF.DateTimeEditors/C1.WPF.DateTimeEditors.C1DateTimePicker.DateTime.html\u0022\u003e.NET Framework\u003c/a\u003e." data-popup-title="C1DateTimePicker.DateTime" data-popup-theme="ui-tooltip-green qtip-green">C1DateTimePicker.DateTime</span> property using XAML or code.


> type=note
> **Note**: Try to avoid avoid setting the **DateTime** property in XAML. Parsing these values from strings is culture specific. If you set a value with your current culture and a user is using different culture, the user can get XamlParseException when loading your site. The best practice is to set these values from code or via data binding.

**In XAML**

Complete the following steps:

1.  Place DateTime="1/17/2010 11:04 AM"to the _<my:C1DateTimePicker>_ tag so that the markup resembles the following:
    
    ```auto
    <my:C1DateTimePicker DateTime="1/17/2010 11:04 AM"/>
    ```
    
2.  Run the project and observe that the **C1DateTimePicker** control shows the date and time as 01/17/2010 11:04:00 AM.

**In Code**

Complete the following steps:

1.  Open the **Window1.xaml.cs** page.
2.  Place the following code beneath the **InitializeComponent()** method:
    
    ```vbnet
    C1DateTimePicker1.DateTime = New DateTime(2010, 1, 17, 11, 04, 0)
    ```
    
    ```csharp
    c1DateTimePicker1.DateTime = new DateTime(2010, 1, 17, 11, 04, 0);
    ```
    
3.  Run the project and observe that the **C1DateTimePicker** control shows the date and time as 01/17/2010 11:04:00 AM.

**This Topic Illustrates the Following**:

The result of this topic resembles the following image:

![](https://cdn.mescius.io/document-site-files/images/b827ed78-bea0-4378-af62-5f467cc00dcc/c1datetimepicker_graphics/tbh/setdatetime_final.png)