Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
May 13, 2002



Application Security Testing: An Integral Part of DevOps

Get Date Format String

There is no native function for returning the current date format string. Here's a simple function that calls the GetLocaleInfo API in order to retrieve the short date format string:
    Private Const LOCALE_SSHORTDATE = &H1F
    Private Const LOCALE_USER_DEFAULT As Long = &H400

    Private Declare Function GetLocaleInfo Lib "KERNEL32" _
        Alias "GetLocaleInfoA" (ByVal lLocale As Long, _
            ByVal lLocaleType As Long, _
            ByVal sLCData As String, _
            ByVal lBufferLength As Long) As Long

    Public Function GetDateFormat() As String
    Dim lReturn As Long
    Dim sBuffer As String
    Dim lBufferLength As Long
        lBufferLength = 128
        sBuffer = String$(lBufferLength, 0)

        lReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, _
sBuffer, lBufferLength)

        If lReturn > 0 Then
            GetDateFormat = Left$(sBuffer, lReturn - 1)
        End If
    End Function
Andreas Hillqvist
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date