SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    sorting date by day/month/year

    Hey guys,
    im trying to get the Date by using the Date() function or objFile.DateLastModified (2 different pages)

    on my localhost it appears fine, the order wanted is day/month/year

    But on brinkster (my web hosting) it is ordered Month/day/year...

    is there any way of changing this to day/month/year?

    thanks for the help

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    675
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there's something new out called "google"

    you should try it with the phrase "UK vs US date vbscript"

    I found this in about 5 seconds:

    Code ASP:
    <%
    Dim MyString, UKDate, USDate
    MyString = Request.Form("Date")
    UKDate = Split(MyString, "/", -1, 1)
    ' UKDate(0) contains "DD".
    ' UKDate(1) contains "MM".
    ' UKDate(2) contains "YY".
    USDate = UKDate(1) & "/" & UKDate(0) & "/" & UKDate(2)
    %>

    I'm sure you can adapt it to your needs

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,204
    Mentioned
    106 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by webber123456 View Post
    there's something new out called "google"

    you should try it with the phrase "UK vs US date vbscript"

    I found this in about 5 seconds:
    Actually, a more consistent approach would be to set the locale (which will set the date format accordingly).

    http://www.w3schools.com/VBscript/func_setlocale.asp
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  4. #4
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    675
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMaxwell View Post
    Actually, a more consistent approach would be to set the locale (which will set the date format accordingly).

    http://www.w3schools.com/VBscript/func_setlocale.asp
    That link is for client-side vbscript and only works in IE browser.

    As I said, I only spent 5 seconds on this.

    If you want to use LCID for ASP this may be of some use. Again, I found this with google very quickly...

    http://msdn.microsoft.com/en-us/libr...8VS.90%29.aspx

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well i cant make it to work, i use it like that:

    Code ASP:
    <%
    Dim MyString, UKDate, USDate
    MyString = Date()
    UKDate = Split(MyString, "/", -1, 1)
    ' UKDate(0) contains "DD".
    ' UKDate(1) contains "MM".
    ' UKDate(2) contains "YY".
    USDate = UKDate(0) & "/" & UKDate(1) & "/" & UKDate(2)
    %>

    and it still displays it as M/D/Y

    SetLocale didnt work either (and yeh im using Chrome)

  6. #6
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    675
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ulthane View Post
    well i cant make it to work, i use it like that:

    Code ASP:
    <%
    Dim MyString, UKDate, USDate
    MyString = Date()
    UKDate = Split(MyString, "/", -1, 1)
    ' UKDate(0) contains "DD".
    ' UKDate(1) contains "MM".
    ' UKDate(2) contains "YY".
    USDate = UKDate(0) & "/" & UKDate(1) & "/" & UKDate(2)
    %>

    and it still displays it as M/D/Y

    SetLocale didnt work either (and yeh im using Chrome)
    you need to learn to debug the code. verify the original date format and compare to the adjusted to learn why desired results are not being obtained.

    Code ASP:
     
    MyString = Date()
    Response.Write "original : <B>" & MyString & "</B><BR>"
    UKDate = Split(MyString, "/", -1, 1)
     
    ' UKDate(0) contains "DD".
    ' UKDate(1) contains "MM".
    ' UKDate(2) contains "YY".
     
    USDate = UKDate(0) & "/" & UKDate(1) & "/" & UKDate(2)
    Response.Write "revised: <B>" & USDate & "</B><BR>"

    correct positions as needed....

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks, worked now the problem was that 0 contained the month and 1 contained the day


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •