devxlogo

Determine Date Format on the Server

Determine Date Format on the Server

Question:
Is there any way I can use ASP to get the date format on the server? I don’t want to return a date and then print it. I want to know the format so that I can instruct the user to enter a date in the correct format, such as dd/mm/yy or dd/mmm/yyyy and so on.

Answer:

You can do this in one of a couple ways. First, you can create your own component DLL using VB. In the DLL, use the Windows API to read the registry settings to obtain the information. Second, you can use the FormatDateTime with short date option on the function Now:

   varD = FormatDateTime(Now, vbShortDate) ' vbshortdate = 2

Then parse through the variable varD and figure out whether it is dd/mm/yy or dd/mm/yyyy.

Also, how many times does your date format on the server change anyway? Just manually access the server and find out the format and hard code it in your ASP code. Sometimes the simplest ways are the best ways.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist