-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimingModel.php
More file actions
75 lines (62 loc) · 1.86 KB
/
Copy pathTimingModel.php
File metadata and controls
75 lines (62 loc) · 1.86 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
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Timing extends CI_Model {
public function index($timezone){
// check for timezone
if (!empty($timezone)) {
date_default_timezone_set($timezone);
}
// set date from php
$datestring = date("Y-m-d h:i:sa");
return $datestring;
}
public function current_time_unix($timezone)
{
// check for timezone
if (!empty($timezone)) {
date_default_timezone_set($timezone);
}else{
$timezone = 'UTC';
date_default_timezone_set($timezone);
}
$this->load->helper('date');
$time = now();
$daylight_saving = TRUE;
// convert to Unix
$unix_time = gmt_to_local($time);
return $unix_time;
}
public function unix_to_time($timestamp)
{
$date = date_create();
// convert to time stamp
date_timestamp_set($date,$timestamp);
//convert to a format
$normal_time = date_format($date,"Y-m-d H:i:s");
return $normal_time;
}
public function time_to_unix($the_time)
{
// format time
$the_time = date("Y-m-d h:i:sa", $the_time);
$daylight_saving = TRUE;
//convert to a format
$unix_time = gmt_to_local($the_time);
return $unix_time;
}
public function extend_time($data)
{
// set the extender
$endtime = strtotime($data);
// extend the time
$endtime = date("Y-m-d h:i:sa", $endtime);
return $endtime;
}
public function extend_time_unix($endstamp,$days)
{
// convert the number of days
$extend = $days*24*60*60;
// extend the time
$endstamp = $endstamp + $extend;
return $endstamp;
}
}