-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.php
More file actions
105 lines (80 loc) · 3.42 KB
/
examples.php
File metadata and controls
105 lines (80 loc) · 3.42 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>EasyDateTime examples</title>
<style>
.text-center {
text-align: center;
color: red;
}
.text-author {
color: dodgerblue;
font-weight: bold;
}
code {
background-color: azure;
}
footer {
text-align: center;
}
</style>
</head>
<body>
<a href="https://github.com/VSG24/EasyDateTime" target="_blank"><h2 class="text-center text-red">
EasyDateTime examples <small>v1.0.0</small></h2></a>
<br>
<?php
require_once __DIR__ . '/vendor/autoload.php';
echo 'All input dates are expected in the <b>UTC</b> format, the methods will try to convert them into the timezone of
the object. If you don\'t want this behaviour you need to set the timezone property to \'UTC\'.';
echo '<hr>';
// Instantiate
echo '<code>$edt = new <b>EasyDateTime</b>(\'Asia/Tehran\', \'jalali\');</code>';
$edt = new EasyDateTime('Asia/Tehran', 'jalali');
echo '<hr>';
echo '<code>$edt-><b>date</b>();</code><br><b>Gets the current datetime - no need for any parameters!</b><br><br>';
echo $edt->date();
echo '<hr>';
echo '<code>$edt-><b>date</b>(\'d l M\');</code><br><br>';
echo $edt->date('d l M');
echo '<hr>';
echo '<code>$edt-><b>date</b>(\'Y-m-d H:i:s\', 1467851310);</code><br><b>Timestamp is in UTC, but the function
converts it to the current EasyDateTime object\'s timezone.</b><br><br>';
echo $edt->date('Y-m-d H:i:s', 1467851310);
echo '<hr>';
echo '<code>$edt-><b>convertNumbers</b>($edt->date());</code><br><br>';
echo $edt->convertNumbers($edt->date());
echo '<hr>';
echo '<code>$edt-><b>timezone</b> = \'America/Los_Angeles\';</code><br><b>Changing timezone can be done
easily at runtime</b><br><br>';
$edt->timezone = 'America/Los_Angeles';
echo $edt->date();
echo '<hr>';
echo '<code>$edt-><b>gregorianStringToJalaliString</b>(\'2016-07-07 00:45\', \'Y-m-d H:i\', \'Y-m-d H:i\');
</code><br><b>Converting Gregorian date-times to Jalali, is a trivial task</b><br><br>';
$edt->timezone = 'Asia/Tehran';
echo $edt->gregorianStringToJalaliString('2016-07-07 00:45', 'Y-m-d H:i', 'Y-m-d H:i');
echo '<hr>';
echo '<code>$edt-><b>jalaliStringToGregorianString</b>(\'1395-04-17 01:14\', \'Y-m-d H:i\');
</code><br><b>The opposite (Jalali to Gregorian) is as easy, though more limited (Read the phpdocs for the method)
</b><br><br>';
echo $edt->jalaliStringToGregorianString('1395-04-17 01:14', 'Y-m-d H:i');
echo '<hr>';
echo '<code>$edt-><b>convertTimeZone</b>(\'2016-07-07 00:00:00\', \'America/Los_Angeles\', \'Asia/Tehran\', \'Y/m/d
H:i:s\');</code><br><b>Converting between timezones is easy and doesn\'n depend on the timezone of the EasyDateTime
object</b><br><br>';
echo $edt->convertTimeZone('2016-07-07 00:00:00', 'America/Los_Angeles', 'Asia/Tehran', 'Y/m/d H:i:s');
echo '<hr>';
?>
<footer>
This project is provided AS IS. It's completely free of charge. This project is licensed under <a href="https://opensource
.org/licenses/MIT">MIT</a> license.
<br>
<a href="https://github.com/vsg24">vsg24 on Github</a> - <a href="http://atvsg.com" target="_blank" class="text-author">Vahid Amiri
Motlagh</a>
<br><br>
</footer>
</body>
</html>