-
Notifications
You must be signed in to change notification settings - Fork 0
/
date.php
54 lines (30 loc) · 1.26 KB
/
date.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
<?php
/** to get time zone of your system */
echo date_default_timezone_get()."<br>";
/** to set time zone of your system */
date_default_timezone_set('Africa/Cairo');
echo date_default_timezone_get()."<br>";
/** function time stamp */
$time = time();
/** get date (specific format from current time) */
$dateFromTime = date('Y-m-d h:i:s',$time);
echo $time." current time<br>";
echo $dateFromTime."<br>";
$futureTime = $time + (30 * 24 * 60 * 60);
echo $futureTime." future time<br>";
echo date('Y-m-d h:i:s',$futureTime)."<br>";
/** to generate time from (hour,minute,second,month,day,year) */
echo mktime(hour:12,minute: 30,second: 30,month: 6,day: 5,year: 2022)."<br>";
echo date('Y-m-d h:i:s A',strtotime('2022-5-6 22:00:00'))."<br>";
echo date('Y-m-d h:i:s A',strtotime('tomorrow'))."<br>";
echo date('Y-m-d h:i:s A',strtotime('first day of march'))."<br>";
echo date('Y-m-d h:i:s A',strtotime('last day of march'))."<br>";
echo date('Y-m-d h:i:s A',strtotime('last day of march 2021'))."<br>";
echo date('Y-m-d h:i:s A',strtotime('second friday of january 2021'))."<br>";
$date = date("Y-m-d",strtotime("+30 day"));
echo "<pre>";
print_r(date_parse($date));
echo "</pre>";
echo "<pre>";
print_r(date_parse_from_format("Y-m-d h:i:s",$date));
echo "</pre>";