HighDots Forums  

Format date & time question...what am I missing?

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Format date & time question...what am I missing? in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jennifer S
 
Posts: n/a

Default Format date & time question...what am I missing? - 07-21-2004 , 11:31 AM






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").Valu e), 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



Reply With Quote
  #2  
Old   
Jennifer S
 
Posts: n/a

Default Re: Format date & time question...what am I missing? - 07-21-2004 , 12:58 PM






Ok,

I don't know if this was the most efficient way of solving this problem but
here's what I came up with so far:

<% newsDate = rsEvents.Fields.Item("EventDate").Value %>
<% =month(newsDate) %>/<% =day(newsDate) %>/<% =Right((year(newsDate)), 2)
%>&nbsp;
<% 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 (AT) plumdropvisions (DOT) com> wrote

Quote:
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").Valu e), 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





Reply With Quote
  #3  
Old   
Kindler Chase
 
Posts: n/a

Default Re: Format date & time question...what am I missing? - 07-21-2004 , 03:20 PM



Jennifer S wrote:
Quote:
Ok,

I don't know if this was the most efficient way of solving this
problem but here's what I came up with so far:
snip
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
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()) %>

--
kindler chase
http://www.ncubed.com
Home of SuperInvoice's Fortress of BeanCounters

news://news.ncubed.com/support
n3 Support Group




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.