Get dates from AUT?

后端 未结 2 1782
迷失自我
迷失自我 2021-01-15 19:47

My Web-based application (like most) follows the browser locale to format dates.

So if you configure British English as the preferred language in the browser, the ap

2条回答
  •  难免孤独
    2021-01-15 20:34

    Not sure about QTP, but the windows scripting host handles it via SetLocale

    Option Explicit
    
    Dim originalLocale
        originalLocale = GetLocale()
    
    Dim aLocales
        aLocales = Array("en-us", "es-es", "de")
    
    Dim locale, aDates, d
    
        For Each locale in aLocales
            WScript.Echo locale
            SetLocale locale
    
            aDates = Array( Date(), DateValue("01/02/2015"))
            For Each d in aDates
                WScript.Echo FormatDateTime(d, 1)
                WScript.Echo FormatDateTime(d, 2)
            Next 
            WScript.Echo "-------------------------------------------------"
        Next
    
        SetLocale originalLocale
    

提交回复
热议问题