| | |
|
|
|
Format date & time question...what am I missing? |
| message from Jennifer S on 21 Jul 2004 |
Hi all,
Ok, this is probably an easy one but I just can't find the answer.
I'm looking to format a date so that the seconds are hidden and the rest
shows. Here's what I'm using now:
<%= DoDateTime((rsEvents.Fields.Item("EventDate").Value), 0, -1) %>
using DW's Format feature. This gives me:
1/14/2005 7:00:00 PM
I would like to have this instead:
1/14/2005 7:00 PM
Like I said, this seems like it should be a simple thing to do. Maybe I'm
searching for the wrong function and/or keywords. Don't know but if anyone
could lend a hand, I would appreciate it. TIA!!!
Jenn S
|
| Jennifer S replied to Jennifer S on 21 Jul 2004 |
Ok,
<% newsDate = rsEvents.Fields.Item("EventDate").Value %>
<% =month(newsDate) %>/<% =day(newsDate) %>/<% =Right((year(newsDate)), 2)
%>
<% If (hour(newsDate) >= 1) and (hour(newsDate) <= 11) Then %>
<% If (minute(newsDate) >= 0) and (minute(newsDate) <= 9) Then %>
<% =hour(newsDate) %>:0<% = minute(newsDate) %>am
<% Else %>
<% =hour(newsDate) %>:<% = minute(newsDate) %>am
<% End If %>
<% Else %>
<% If (minute(newsDate) >= 0) and (minute(newsDate) <= 9) Then %>
<% =hour(newsDate) - 12 %>:0<% = minute(newsDate) %>pm
<% Else %>
<% =hour(newsDate) - 12 %>:<% = minute(newsDate) %>pm
<% End If %>
<% End If %>
This actually gave me a little more control over the format of the am & pm
too.
Anyone else know of a more efficient way of not showing the seconds?
Thanks!
Jenn
"Jennifer S" <subscriptions@plumdropvisions.com> wrote in message
news:cdm28j$iu5$1@forums.macromedia.com...
|
| Kindler Chase replied to Jennifer S on 21 Jul 2004 |
<snip>
Formatting date/time's can be obtuse at times. If you want complete control
over your date format, take a look at the function on 4guys:
http://www.4guysfromrolla.com/webtech/022701-1.shtml
May look a tad intimidating at first, but will make sense after you play
with it a bit - also, be sure ot look at the live sample on the page which
should help you out with understanding the function.
If all you want is format the date w/o the seconds, then you'll need to
write a custom function, sort of like what you already did. Here's an
example of writing a smallish function to handle what you're doing:
<% option explicit
Private Function n3_DateTime(DateTime)
'Create a unique name
Dim dtDate, intYear, intMonth, intDay
Dim intHour, intMinute, intSecond, strAmPm
Dim d 'the date divider
Dim t 'the time divider
d = "/"
t = ":"
dtDate = DateTime
intYear = year(dtDate)
intMonth = Right("0" & month(dtDate),2)
intDay = Right("0" & day(dtDate),2)
intHour = Right("0" & hour(dtDate),2)
intMinute = Right("0" & minute(dtDate),2)
intSecond = Right("0" & second(dtDate),2)
If DatePart("h",dtDate) >= 12 Then
strAmPm = "pm"
Else
strAmPm = "am"
End If
'Now put it all together in a nice little format
n3_DateTime = intMonth & d & intDay & d & intYear & _
" " & intHour & t & intMinute & " " & strAmPm
End Function
%>
<%= (Now()) %>
<br />
<br />
<%= n3_DateTime(Now()) %>
|
|
Archived message: Format date & time question...what am I missing? (Macromedia Dreamweaver)