United Kingdom Date Converter by David Loheman

Contributed by
Rating:  stars stars stars stars stars / 0
October 01, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

United Kingdom Date Converter by David Lohmann

In answer to the many forum posts I see regarding date formats, here is a code snippet which will display the date in UK format (dd/mm/yyyy) regardless of server location.

First it splits the date into an array, then checks whether the first array element represents the current month. If so it rearranges the string accordingly. If the server date just happens already to be in UK format, it simply reconstructs the original string. 

The date in the UK is

16/07/2003


Code that runs this demo

<%
'Use this code freely. Just remember me when you're recruiting!
'Dave Lohmann dloh@uk2.net


Sub ShowUKdate()

dim dateStr, UKdate
dateStr=split(date,"/")

'add leading zero to single figures

    if Len(dateStr(0))<2 then
        dateStr(0)="0"&dateStr(0)
    end if

    if Len(dateStr(1))<2 then
        dateStr(1)="0"&dateStr(1)
    end if

    if Int(dateStr(0))=month(now) then
        UKdate=dateStr(1)&"/"&dateStr(0)&"/"&dateStr(2)
    else
        UKdate=join(dateStr,"/")
    end if

    response.write UKdate
    End Sub
%>


The date in the UK is <% ShowUKdate %>

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials