Copy link to clipboard
Copied
OK so I know that this should be easy.
My computer is setup so that dates are displayed in english format dd/mm/yyyy.
I am designing ASP pages and want a readonly field that takes its value from =(now). he result is always in American format mm/dd/yyyy.
See code:
<td><span id="spryID">
<input name="id" type="text" id="id" value="<%=(now)%>" readonly="readonly" />
</span></td>
Output is always:
1/20/2010 09:34:52 AM and not 20/1/2010 09:34:52 AM
How can I format the output to get the corect format I require?
Copy link to clipboard
Copied
I found a date utility function several years ago and just continually format it for my needs. Give this a whirl:
' Drop this in an include file somewhere so you can reference it.
function amDate(varDate)
if isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
amDate = "Null"
else
amDate = Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & " " & TimeValue(varDate)
end if
end function
'Call the function as I have below:
<td><span id="spryID">
<input name="id" type="text" id="id" value="<%=(amDate(now()))%>" readonly="readonly" />
</span></td>
Hope that helps you,
Joe Jenkins
mrwebguy
Copy link to clipboard
Copied
Thanks Joe
Your function does exactly what I need.
Ian
Copy link to clipboard
Copied
Excellent, I'm glad I was able to help.
Thanks,
Joe Jenkins