Author: | kartik-v |
---|---|
Views Total: | 90 views |
Official Page: | Go to website |
Last Update: | July 16, 2020 |
License: | MIT |
Preview:

Description:
php-date-formatter is a tiny JavaScript DateTime manipulation library to parse and format DateTime strings using PHP Date and Time formats.
How to use it:
1. Download the package and place the JavaScript php-date-formatter.js
into your document.
<script src="./js/php-date-formatter.js"></script>
2. Initialize the library.
var instance = new DateFormatter();
3. Convert a DateTime string into a Javascript Date Object by passing any of the PHP DateTime formats.
var date = instance.parseDate('2020-06-17 12:24:06', 'Y-m-d H:i:s');
4. Format a DateTime string.
var date2 = fmt.formatDate(date, 'D, M jS, Y g:i:s A');
5. PHP DateTime formats:
Format | Value |
---|---|
d | 17 |
D | Wed |
j | 17 |
l | Wednesday |
N | 3 |
w | 3 |
z | 168 |
W | 25 |
F | June |
m | 06 |
M | Jun |
n | 6 |
t | 30 |
L | 1 |
o | 2020 |
Y | 2020 |
y | 20 |
a | pm |
A | PM |
B | 225 |
g | 12 |
G | 12 |
h | 12 |
H | 12 |
i | 24 |
s | 06 |
u | 000000 |
e | Greenwich Mean Time |
I | 0 |
O | +0800 |
P | +08:00 |
T | GMT+0800 |
Z | 28800 |
c | 2020-06-17T12:24:06+08:00 |
r | Wed, 17 Jun 2020 12:24:06 +0800 |
U | 1592367846 |