Skip to content

Commit c0dd863

Browse files
committed
✨ add date(), fixDate() and fixDatetime() methods
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 5998312 commit c0dd863

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

Core/core/Helpers/Format.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Format class
55
* Help convert between various formats such as XML, JSON, CSV, etc.
66
*
7-
* @author Phil Sturgeon, Chris Kacerguis, @softwarespot
7+
* @author Phil Sturgeon, Chris Kacerguis, Kwame Oteng Appiah-Nti, @softwarespot
88
* @license http://www.dbad-license.org/
99
*/
1010

@@ -127,6 +127,46 @@ public static function factory($data, $from_type = null)
127127
return new static($data, $from_type);
128128
}
129129

130+
// FORMATTING DATE & TIME ---------------------------------------------------------
131+
132+
/**
133+
* Take date and set a custom date format
134+
*
135+
* @param string $format
136+
* @param string $date
137+
* @return string
138+
*/
139+
public function date($format, $date)
140+
{
141+
return format_date($format, $date);
142+
}
143+
144+
/**
145+
* Take date and format it in Y-m-d
146+
* This fixes a date and can be stored
147+
* and used easily
148+
*
149+
* @param string $date
150+
* @return string
151+
*/
152+
public function fixDate($date)
153+
{
154+
return correct_date($date);
155+
}
156+
157+
/**
158+
* Take datetime and format it in Y-m-d H:i:a
159+
* This fixes a datetime and can be stored
160+
* and used easily
161+
*
162+
* @param string $datetime
163+
* @return string
164+
*/
165+
public function fixDatetime($datetime)
166+
{
167+
return correct_datetime($datetime);
168+
}
169+
130170
// FORMATTING OUTPUT ---------------------------------------------------------
131171

132172
/**

0 commit comments

Comments
 (0)