Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DateTimePicker with Custom Format: DateTimePickerFormat.Short + DateTimePickerFormat.Time?

Posted on 2008-10-15
4
Medium Priority
?
1,923 Views
Last Modified: 2012-05-05
I have an application that is used worldwide. I use datetimepickers and the format needs to be <Short date> <Short Time>.
It doesn't appear that there is a way to do this. Using a custom format doesn't work because USA uses: MM/dd/yyy and many other countries use dd/MM/yyyy. I can't imagine that Microsoft wouldn't make a way to do this. What am I missing?
0
Comment
Question by:gcook17
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 22725031
The format strings can be combined to format the date and time. For example, to display the date and time as 06/15/2001 12:00 PM, this property should be set to "MM'/'dd'/'yyyy hh':'mm tt".

So add any other special characters in btw.

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"  'Another Formatter
0
 

Author Comment

by:gcook17
ID: 22725123
Thank you for your comment however I am aware of this: that you can combine the format strings. The problem with this is: With USA this format is fine: "MM'/'dd'/'yyyy hh':'mm tt" But with UK and many other countries the fomat must be "dd/MM/'yyyy hh':'mm tt. In VB6 yiu could concatenate "Short Date" & ' ' & "Short Time" to obtain the correct format regardless of the Regional Locale settings.
0
 
LVL 25

Accepted Solution

by:
apeter earned 2000 total points
ID: 22725480
1. Get the date from the date picker.
2. Create a date object from above value.
3. DateTime has two methods, ToShortDateString and ToShortTimeString(). Concatenate them.

Dim instance As DateTime
Dim returnValue As String
Dim instance As New DateTime(year, month, day)
returnValue = instance.ToShortDateString()

0
 

Author Closing Comment

by:gcook17
ID: 31506465
Thanks.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question