Aleks
asked on
Display date and time
I am using ASP/VB and on my page I am trying to display the date and time, I am using: <% =now %>
And that is great but it shows 9/18/2015 9:00:00 AM
And I need for it to be: 09/18/2015 9:00:00
And if its 8 pm it should be: 09/18/2015 20:00:00
I am not sure how to do this.
And that is great but it shows 9/18/2015 9:00:00 AM
And I need for it to be: 09/18/2015 9:00:00
And if its 8 pm it should be: 09/18/2015 20:00:00
I am not sure how to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i would split up that line in peaces, and see where it fails.
ASKER
I am not sure how to do that. I took out the time but still got the same issue.
ASKER
Can someone please help with the script ? I can't seem to make that one work. I don't mind using a new one if needed.
ASKER
This worked:
<% function todayStr()
dim theDate, theDay, theMonth
theDate = FormatDateTime( now, 2)
theMonth = Month(theDate)
if CInt( theMonth ) < 10 then theMonth = "0" & theMonth
theDay = Day( theDate )
if CInt( theDay ) < 10 then theDay = "0" & theDay
todayStr = theMonth & "/" & theDay & "/" & Year(theDate)&" "&formatdatetime(now,3)
end function
%>
<% function todayStr()
dim theDate, theDay, theMonth
theDate = FormatDateTime( now, 2)
theMonth = Month(theDate)
if CInt( theMonth ) < 10 then theMonth = "0" & theMonth
theDay = Day( theDate )
if CInt( theDay ) < 10 then theDay = "0" & theDay
todayStr = theMonth & "/" & theDay & "/" & Year(theDate)&" "&formatdatetime(now,3)
end function
%>
ASKER
Good try
ASKER
Open in new window
Displaying:
value="<%=todayStr()%>"
Error: Microsoft VBScript runtime error '800a000d'
Type mismatch: 'todayStr'