Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Date format in American (ASP)

Guest
Jan 20, 2010 Jan 20, 2010

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?

TOPICS
Server side applications
411
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 21, 2010 Jan 21, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 21, 2010 Jan 21, 2010

Thanks Joe

Your function does exactly what I need.

Ian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 21, 2010 Jan 21, 2010
LATEST

Excellent, I'm glad I was able to help.

Thanks,

Joe Jenkins

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines