Skip to content

Date format

Jiří Škoda edited this page Mar 26, 2024 · 6 revisions

This page is dedicated to format of date used in PHP-Movic. PHP-Movic date and time utilities works only with simplified syntax. If you want use any more advanced formatting, you can always use default PHP date and time format.

Content
1. General syntax
2. Time symbols
3. Date symbols

General syntax

General syntax of date format string is following:
%X%
Where X is any of time or date symbol.

This sequence can be repeated as many times, as you want, for example:
%X%.%Y%.%Z% %a%:%b%:%c%
As long as X, Y, Z, a, b, c are any of symbols, all characters outside % will be outputted as they are.

All symbols are case sensitive (M is not same thing like m).

Time symbols

For any of following examples, let's assume time 07:09:03.5 in the morning.

Symbol Explanation Example
H Hour in 24 hours format 7
0H Zero padded hour in 24 hours format 07
G Hour in 12 hours format 7
0G Zero padded hour in 12 hours format 07
M Minutes 9
0M Zero padded minutes 09
S Seconds 3
0S Zero padded seconds 03
U Milliseconds 5
0U Zero padded milliseconds 50
LP Lower cased name of period am
UP Upper cased name of period AM

Date symbols

PHP-Movic does not work with any kind of format which would need any translation. So, any format works only with numeric values. This means, that PHP-Movic date formats does not support day of week (Friday, etc.) or names of months (June, etc.).
For following examples is used following date: 1st January 2023.

Symbol Explanation Example
d Day in month (1 to 31) 1
0d Zero padded day in month 01
m Number of month, where 1 is January 1
0m Zero padded number of month 01
y Full length year 2023
s Shortened year (last two digits) 23

Clone this wiki locally