How can I format any date to dd/mm/yy format in ASP? it seams to have the Format() Function missing :(
Printable View
How can I format any date to dd/mm/yy format in ASP? it seams to have the Format() Function missing :(
hummm,
you can use
formatDateTime(yourDate,vbShortDate)
but it is in
mm/dd/yy
for dd/mm/yy i don't know!!
formatDateTime(yourDate,"dd/mm/yy") will probaly work then
Cheers
did it work for you?!Quote:
Originally posted by chenko
formatDateTime(yourDate,"dd/mm/yy") will probaly work then
Cheers
I believe formatdatatime requires a named format. In order to do 'dd/mm/yyyy' you have to change your shortdate format in the region settings of the server to match that, then use formatdatetime(date, vbShortDate)
1. Write a Dll in VB that wraps the Format() function and create an object from this Dll in your ASP code. :)
2. Write your own custom date function in your ASP that uses the Day(), Month(), and Year() functions to put your date into the format you desire. For example:
PaulCode:<%
Function FormatDateCustom(DateToFormat)
Dim strReturn
Dim strTemp
' Day.
strTemp = Day(DateToFormat)
If Len(strTemp) = 1 Then
strTemp = "0" & strTemp
End If
strReturn = strTemp
' Month.
strTemp = Month(DateToFormat)
If Len(strTemp) = 1 Then
strTemp = "0" & strTemp
End If
strReturn = strReturn & "/" & strTemp
' Year.
strTemp = Mid(Year(DateToFormat), 3, 2)
strReturn = strReturn & "/" & strTemp
FormatDateCustom = strReturn
End Function
' Which could be called like:
Response.Write "<P>" & FormatDateCustom(Now) & "</P>" & vbcrlf
%>
I wrote one a while ago, here it is attached, just download it and register it.
usage....
Code:set o = server.createobject("aspformat.format")
mystring = o.formatstring(now, "dd-mmm-yyyy hh:nn:ss")
Quote:
Originally posted by MadWorm
I wrote one a while ago, here it is attached, just download it and register it.
usage....
Code:set o = server.createobject("aspformat.format")
mystring = o.formatstring(now, "dd-mmm-yyyy hh:nn:ss")
Ahem: I wrote that code today. Who do you think you are?:mad:
Please forgive me, I had the same brainstorm May last year, see the date on the DLL, very useful, I've used it heaps.:)
I am a bit lost here, am i the only one :confused:. :rolleyes:Quote:
Originally posted by jesus4u
Ahem: I wrote that code today. Who do you think you are?:mad:
I havent had a look at any one of your code, but looking at what you have posted, i have to say its a very common method. i myself has written very similar functions to format date and time which i reuse in my applications.
Sorry to sound accusatory but the odds are great that you would post the exact same name for a dll that I did yesterday!Quote:
Originally posted by MadWorm
I wrote one a while ago, here it is attached, just download it and register it.
usage....
Code:set o = server.createobject("aspformat.format")
mystring = o.formatstring(now, "dd-mmm-yyyy hh:nn:ss")
:rolleyes: