dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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, _
LOCALE_SSHORTDATE, 
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.

 

 

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