@@ -152,7 +152,7 @@ public static function to_timestamp($date) {
152152 * - onlytime: HH:MM
153153 * - rss: Rss time format for XML
154154 * - nice: if you prepend a nice: (like nice:long) you will get results like "today" or "yesterday" if applicable
155- * - custom: you can give a strftime format like %d.%m.%Y %H:%M if you prepend custom: to it
155+ * - custom: you can give a php date function format like d.m.Y H:i if you prepend custom: to it
156156 * @param bool $time if true apped the time to the date string
157157 * @param bool $seconds if true append the seconds to the time
158158 * @return string date string
@@ -174,15 +174,15 @@ public static function to_string($date, $format = 'short', $time = false, $secon
174174 $ fmt = '' ;
175175 $ prepend = '' ;
176176 if (substr ($ format , 0 , 5 ) == 'nice: ' ) {
177- if (strftime ( ' %d.%m.% Y ' , $ date ) == strftime ( ' %d.%m.% Y ' , $ portal ->getTime ())) {
177+ if (date ( ' d.m. Y ' , $ date ) == date ( ' d.m. Y ' , $ portal ->getTime ())) {
178178 if ($ time == true ) $ format = 'onlytime ' ;
179179 else $ format = '' ;
180180 $ prepend = 'Heute ' ;
181- } elseif (strftime ( ' %d.%m.% Y ' , $ date ) == strftime ( ' %d.%m.% Y ' , $ portal ->getTime () - 86400 )) {
181+ } elseif (date ( ' d.m. Y ' , $ date ) == date ( ' d.m. Y ' , $ portal ->getTime () - 86400 )) {
182182 if ($ time == true ) $ format = 'onlytime ' ;
183183 else $ format = '' ;
184184 $ prepend = 'Gestern ' ;
185- } elseif (strftime ( ' %d.%m.% Y ' , $ date ) == strftime ( ' %d.%m.% Y ' , $ portal ->getTime () + 86400 )) {
185+ } elseif (date ( ' d.m. Y ' , $ date ) == date ( ' d.m. Y ' , $ portal ->getTime () + 86400 )) {
186186 if ($ time == true ) $ format = 'onlytime ' ;
187187 else $ format = '' ;
188188 $ prepend = 'Morgen ' ;
@@ -195,21 +195,21 @@ public static function to_string($date, $format = 'short', $time = false, $secon
195195 $ time = false ;
196196 }
197197
198- if ($ format == 'short ' ) $ fmt = '%d.%m.% y ' ;
199- elseif ($ format == 'veryshort ' ) $ fmt = '%d.% m. ' ;
200- elseif ($ format == 'medium ' ) $ fmt = '%d.%m.% Y ' ;
201- elseif ($ format == 'long ' ) $ fmt = '% d. %B % Y ' ;
202- elseif ($ format == 'extra ' ) $ fmt = '% A, % d. %B % Y ' ;
203- elseif ($ format == 'day ' ) $ fmt = '% d ' ;
204- elseif ($ format == 'monthnum ' ) $ fmt = '% m ' ;
205- elseif ($ format == 'shortmonth ' ) $ fmt = '% b ' ;
206- elseif ($ format == 'month ' ) $ fmt = '% B ' ;
207- elseif ($ format == 'shortyear ' ) $ fmt = '% y ' ;
208- elseif ($ format == 'year ' ) $ fmt = '% Y ' ;
209- elseif ($ format == 'onlydate ' ) $ fmt = '%d.% m. ' ;
210- elseif ($ format == 'onlydatelong ' ) $ fmt = '% d. % B ' ;
198+ if ($ format == 'short ' ) $ fmt = 'd.m. y ' ;
199+ elseif ($ format == 'veryshort ' ) $ fmt = 'd. m. ' ;
200+ elseif ($ format == 'medium ' ) $ fmt = 'd.m. Y ' ;
201+ elseif ($ format == 'long ' ) $ fmt = 'd. B Y ' ;
202+ elseif ($ format == 'extra ' ) $ fmt = 'A, d. B Y ' ;
203+ elseif ($ format == 'day ' ) $ fmt = 'd ' ;
204+ elseif ($ format == 'monthnum ' ) $ fmt = 'm ' ;
205+ elseif ($ format == 'shortmonth ' ) $ fmt = 'b ' ;
206+ elseif ($ format == 'month ' ) $ fmt = 'B ' ;
207+ elseif ($ format == 'shortyear ' ) $ fmt = 'y ' ;
208+ elseif ($ format == 'year ' ) $ fmt = 'Y ' ;
209+ elseif ($ format == 'onlydate ' ) $ fmt = 'd. m. ' ;
210+ elseif ($ format == 'onlydatelong ' ) $ fmt = 'd. B ' ;
211211 elseif ($ format == 'onlytime ' ) {
212- $ fmt = '%H:%M ' ;
212+ $ fmt = 'H:i ' ;
213213 $ time = false ;
214214 } elseif ($ format == 'rss ' ) {
215215 $ ret = date (DATE_RSS , $ date );
@@ -220,9 +220,9 @@ public static function to_string($date, $format = 'short', $time = false, $secon
220220 if ($ prepend != '' ) $ ret = $ prepend . ' ' . $ ret ;
221221 return $ ret ;
222222 }
223- if ($ time == true ) $ fmt .= ' %H:%M ' . ($ seconds == true ? ':%S ' : '' );
223+ if ($ time == true ) $ fmt .= ' H:i ' . ($ seconds == true ? ':s ' : '' );
224224
225- if ($ fmt != '' ) $ ret = strftime ($ fmt , $ date );
225+ if ($ fmt != '' ) $ ret = date ($ fmt , $ date );
226226 else $ ret = '' ;
227227
228228 if ($ prepend != '' ) $ ret = trim ($ prepend . ' ' . $ ret );
@@ -249,10 +249,10 @@ public static function to_string($date, $format = 'short', $time = false, $secon
249249 * @return mixed either int (months) or array of int (0 => years, 1 => months) or FALSE on invalid dates
250250 */
251251 public static function months_between ($ date_from , $ date_to , $ return_years = false , $ include_both = false ) {
252- $ date_from = self ::to_string ($ date_from , 'custom:%Y%m ' );
252+ $ date_from = self ::to_string ($ date_from , 'custom:Ym ' );
253253 if ($ date_from === false ) return $ date_from ;
254254
255- $ date_to = self ::to_string ($ date_to , 'custom:%Y%m ' );
255+ $ date_to = self ::to_string ($ date_to , 'custom:Ym ' );
256256 if ($ date_to === false ) return $ date_to ;
257257
258258 $ date_from = intval ($ date_from );
@@ -294,12 +294,12 @@ public static function months_between($date_from, $date_to, $return_years = fals
294294 * @return mixed either int (days) or FALSE on invalid dates
295295 */
296296 public static function days_between ($ date_from , $ date_to , $ include_both = false ) {
297- $ date_from = self ::to_string ($ date_from , 'custom:%Y-%m-% d ' );
297+ $ date_from = self ::to_string ($ date_from , 'custom:Y-m- d ' );
298298 if ($ date_from === false ) return $ date_from ;
299299 list ($ y , $ m , $ d ) = explode ('- ' , $ date_from );
300300 $ ts_from = mktime (0 , 0 , 0 , $ m , $ d , $ y );
301301
302- $ date_to = self ::to_string ($ date_to , 'custom:%Y-%m-% d ' );
302+ $ date_to = self ::to_string ($ date_to , 'custom:Y-m- d ' );
303303 if ($ date_to === false ) return $ date_to ;
304304 list ($ y , $ m , $ d ) = explode ('- ' , $ date_to );
305305 $ ts_to = mktime (0 , 0 , 0 , $ m , $ d , $ y );
@@ -364,7 +364,7 @@ public static function sql_date($date = false, $no_time = false) {
364364 if ($ date === false ) $ date = $ portal ->getTime (true );
365365
366366 if (is_numeric ($ date )) {
367- return $ no_time ? strftime ( ' %Y-%m-% d ' , $ date ) : strftime ( ' %Y-%m-%d %H:%M:%S ' , $ date );
367+ return $ no_time ? date ( ' Y-m- d ' , $ date ) : date ( ' Y-m-d H:i:s ' , $ date );
368368 }
369369
370370 if (preg_match ('/^(.*)(\d{1,2}:\d{1,2}(:\d{1,2})?)(\D|$)/ ' , $ date , $ matches )) {
@@ -473,7 +473,7 @@ public static function calc_age($date) {
473473 if ($ date === false ) return $ date ;
474474
475475 list ($ year , $ month , $ day ) = explode ('- ' , $ date );
476- list ($ curyear , $ curmonth , $ curday ) = explode ('- ' , strftime ( ' %Y-%m-% d ' , $ portal ->getTime ()));
476+ list ($ curyear , $ curmonth , $ curday ) = explode ('- ' , date ( ' Y-m- d ' , $ portal ->getTime ()));
477477
478478 $ year_diff = $ curyear - $ year ;
479479 $ month_diff = $ curmonth - $ month ;
0 commit comments