Skip to main content
Known Participant
October 3, 2008
Question

Outputting Time

  • October 3, 2008
  • 3 replies
  • 610 views
Hi all,

I've started using dates/times on my websites stored in a date/time field in my database. In the past, when I typed in times on my site rather than pulled them from a database, I formatted them slightly different than CF does. For example, if the time was 9 in the morning, I would key in 9 a.m. on my site. However, because of the date/time field in Access, the time gets output as 9:00 AM. Two questions: 1) Is there a way to drop the two zeros and 2) Can I make AM/PM show up as a.m./p.m.

I know it seems extremely picky, but I want this great transition to dynamic dates to be seemless for my users.

Thanks!
    This topic has been closed for replies.

    3 replies

    Inspiring
    October 6, 2008
    Try lcase instead of replace.
    straffenpAuthor
    Known Participant
    October 6, 2008
    Thanks for the tip. This works for both am/pm, but now I lose the periods (a.m./p.m.) Is there any way to get those back?
    Inspiring
    October 3, 2008
    Don't worry about how it looks in Access. That's got nothing to do with how it will look on your site.
    straffenpAuthor
    Known Participant
    October 3, 2008
    Maybe I'm missing something. Right now, with the formatting I'm using, the time looks the same as it does in the database.

    Here is the format I have in place right now: #TimeFormat(StartTime, "h:mm tt")# If the time is 9 in the morning, CF outputs it as 9:00 AM. I'd like it to show up as 9 a.m. If the time is 9:30 in the morning, CF outputs 9:30 AM. I'd like it to show up as 9:30 a.m. Does that explain things a little clearer?

    Thanks!
    Inspiring
    October 3, 2008
    Presuming that you are now using proper date/time objects like you
    should be from your database. Then you just need to look at the
    timeFormat() function which can do all you want and more.