-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
63 lines (55 loc) · 1.62 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
include 'PDate.php';
$config = [
'dateTime' => '2018-10-11',
'local' => 'en_US',//default: php.ini config
'inTimeZone' => 'Asia/Tehran',//default: php.ini config
'inFormat' => 'Y-m-d',
'outTimeZone' => 'Asia/Tehran',//default: php.ini config
'outFormat' => 'y-M-d'
];
//or
$config = [
'y'=>2018,
'm'=>10,
'd'=>11,
'local' => 'en_US',//default: php.ini config
'inTimeZone' => 'Asia/Tehran',//default: php.ini config
'outTimeZone' => 'Asia/Tehran',//default: php.ini config
'inFormat' => 'Y-m-d',
'outFormat' => 'y-M-d'
];
$pDate = new PDate(); //or $pDate = new PDate($config)
$pDate->setConfig($config);
//NOTE: p2g() and g2p() methods aregumants are same
echo $pDate->g2p(); //output: 1397-7-19 (get date from $config)
echo $pDate->g2p([2018 , 11 , 10]); //output: 1397-7-19
echo $pDate->g2p('2018-11-10'); //output: 1397-7-19
echo $pDate->g2p('2018-11-10', 'y-M-d'); //output: 1397-7-19
echo $date->now(); //output: current date
echo $date->now('y-M-d'); //output: current date with specific format
//an example from pArchive output
var_dump($pDate->pArchive(3));
/**
putput:
array (size=3)
0 =>
array (size=4)
0 => string '2018-10-23' (length=10)
1 => string '2018-11-9' (length=9)
'year' => int 1397
'month' => int 8
1 =>
array (size=4)
0 => string '2018-9-23' (length=9)
1 => string '2018-10-22' (length=10)
'year' => int 1397
'month' => int 7
2 =>
array (size=4)
0 => string '2018-8-23' (length=9)
1 => string '2018-9-22' (length=9)
'year' => int 1397
'month' => int 6
*/
?>