Skip to content

Commit 1b00771

Browse files
committed
date format applied
1 parent 0e1f32c commit 1b00771

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

includes/Models/Taxonomy.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class Taxonomy extends Eloquent {
1818

1919
public $timestamps = false;
2020

21+
protected $appends = [
22+
'formatted_add_date',
23+
'formatted_mod_date'
24+
];
25+
2126
/**
2227
* Get the options for generating the slug.
2328
*/
@@ -110,4 +115,40 @@ public function delete() {
110115

111116
return $delete;
112117
}//end method delete
118+
119+
/**
120+
* get formatted add date
121+
*
122+
* @return string
123+
*/
124+
public function getFormattedAddDateAttribute() {
125+
if ( ! isset( $this->attributes['id'] ) ) {
126+
return '';
127+
}
128+
if ( ! isset( $this->attributes['add_date'] ) ) {
129+
return '';
130+
}
131+
132+
$format = get_option('date_format') . ' ' . get_option('time_format');
133+
134+
return date_i18n($format, strtotime($this->attributes['add_date']));
135+
}//end method getFormattedAddDateAttribute
136+
137+
/**
138+
* get formatted mod date
139+
*
140+
* @return string
141+
*/
142+
public function getFormattedModDateAttribute() {
143+
if ( ! isset( $this->attributes['id'] ) ) {
144+
return '';
145+
}
146+
if ( ! $this->attributes['mod_date'] ) {
147+
return '';
148+
}
149+
150+
$format = get_option('date_format') . ' ' . get_option('time_format');
151+
152+
return date_i18n($format, strtotime($this->attributes['mod_date']));
153+
}//end method getFormattedModDateAttribute
113154
}//end class Taxonomy

0 commit comments

Comments
 (0)