Formatting Dates

Webvanta stores dates and time in a format-independent representation, and you can choose the format when you display it.

The format string uses the "strftime" format that has been used in many languages. These are the options:

%aThe abbreviated weekday name ("Sun")
%AThe full weekday name ("Sunday")
%bThe abbreviated month name ("Jan")
%BThe full month name ("January")
%cThe preferred local date and time representation
%dDay of the month (01..31)
%eDay of the month without leading zeroes (1..31)
%HHour of the day, 24-hour clock (00..23)
%IHour of the day, 12-hour clock (01..12)
%jDay of the year (001..366)
%kHour of the day, 24-hour clock w/o leading zeroes ( 0..23)
%lHour of the day, 12-hour clock w/o leading zeroes ( 1..12)
%mMonth of the year (01..12)
%MMinute of the hour (00..59)
%pMeridian indicator ("AM" or "PM")
%PMeridian indicator ("am" or "pm")
%SSecond of the minute (00..60)
%UWeek number of the current year, starting with the first Sunday as the first day of the first week (00..53)
%WWeek number of the current year, starting with the first Monday as the first day of the first week (00..53)
%wDay of the week (Sunday is 0, 0..6)
%yYear without a century (00..99)
%YYear with century
%ZTime zone name
%zTime zone expressed as a UTC offset ("-04:00")
%%Literal "%" character

Any text in the format string that is not preceded by a % symbol is rendered as ordinary text.

Here are some examples:

<w:date format="%A %B %e, %Y %l:%M %P" /> Saturday July 4, 2022 1:32 pm
<w:date format="%a %b %e '%y %k:%M" /> Sat Jul 4 '09 13:32
<w:date format="%m/%e/%Y" /> 07/4/2022

Comments

2 comments

"Time ago" format option

From: Michael Slater, 11/11/09

There is an experimental format option called "time_ago" that does what you're looking for. <w:updated_at format="time_ago" /> ago

Time as 'ago'.

From: Jane, 11/09/09

Is it possible to specify the date as time ago, eg. '6 weeks, 3 days ago'? Useful for listing recent blog entries.


Add Your Comments

(not published)

Join our Free Learning Webvanta Course

We'll send you a series of brief lessons and tips on making the most of Webvanta. In less than a month you'll be an expert at building powerful, database-driven sites.

Name:
Email:

We hate spam as much as you do. We'll use your address only for sending you this course and Webvanta updates.

Related Articles