Determine Date Format on the Server

Determine Date Format on the Server

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.


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.


Share the Post: