Parse And Format Datetime Strings Using PHP DateTime Formats

Category: Date & Time , Javascript | July 16, 2020
Author:kartik-v
Views Total:76 views
Official Page:Go to website
Last Update:July 16, 2020
License:MIT

Preview:

Parse And Format Datetime Strings Using PHP DateTime Formats

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:

FormatValue
d17
DWed
j17
lWednesday
N3
w3
z168
W25
FJune
m06
MJun
n6
t30
L1
o2020
Y2020
y20
apm
APM
B225
g12
G12
h12
H12
i24
s06
u000000
eGreenwich Mean Time
I0
O+0800
P+08:00
TGMT+0800
Z28800
c2020-06-17T12:24:06+08:00
rWed, 17 Jun 2020 12:24:06 +0800
U1592367846

You Might Be Interested In:


Leave a Reply