Solved

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

Posted on 2008-10-15
4
1,825 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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now