Skip to content

Commit c0e5ec8

Browse files
authored
Merge pull request #160 from hos3ein/master
Add new converter methods
2 parents 1c7379e + e4fb606 commit c0e5ec8

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/Converter.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function toFormattedDateString()
3939
*
4040
* @return string
4141
*/
42-
public function toFormattedDayDateString(): string
42+
public function toFormattedDayDateString()
4343
{
4444
return $this->format('l j F Y');
4545
}
@@ -68,6 +68,18 @@ public function toDateTimeString($unitPrecision = 'second')
6868
return $this->format('Y/m/d ' . static::getTimeFormatByPrecision($unitPrecision));
6969
}
7070

71+
/**
72+
* Format the instance as a readable date and time
73+
*
74+
* @param string $unitPrecision
75+
*
76+
* @return string
77+
*/
78+
public function toFormattedDateTimeString($unitPrecision = 'second')
79+
{
80+
return $this->format('j F Y ' . static::getTimeFormatByPrecision($unitPrecision));
81+
}
82+
7183
/**
7284
* Return a format from H:i to H:i:s.u according to given unit precision.
7385
*
@@ -110,11 +122,23 @@ public function toDateTimeLocalString($unitPrecision = 'second')
110122
/**
111123
* Format the instance with day, date and time
112124
*
125+
* @param string $unitPrecision
126+
*
127+
* @return string
128+
*/
129+
public function toDayDateTimeString($unitPrecision = 'second')
130+
{
131+
return $this->format('l j F Y ' . static::getTimeFormatByPrecision($unitPrecision));
132+
}
133+
134+
/**
135+
* Format the instance with the year, and a readable month
136+
*
113137
* @return string
114138
*/
115-
public function toDayDateTimeString()
139+
public function toFormattedMonthYearString()
116140
{
117-
return $this->format('l j F Y g:i A');
141+
return $this->format('F Y');
118142
}
119143

120144
}

0 commit comments

Comments
 (0)