Skip to content

Commit d40f45d

Browse files
committed
docs: add timezone to the timestamp example so readers can see the output depends on their server's timezone
1 parent 1b22a1f commit d40f45d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

docs/text-and-formatting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ echo $date->dateFormat(); // May 15th, 2026
142142
```
143143

144144
There is one method for dates and datetimes; the format string decides what
145-
shows. Numeric values are treated as unix timestamps; everything else is
146-
parsed with `strtotime()`:
145+
shows. Numeric values are treated as unix timestamps and format in your
146+
server's PHP timezone; everything else is parsed with `strtotime()`:
147147

148148
```php
149-
echo SmartString::new(1684159800)->dateFormat('Y-m-d'); // 2023-05-15
149+
echo SmartString::new(1684159800)->dateFormat('Y-m-d T'); // 2023-05-15 PDT
150150
```
151151

152152
Invalid dates return null rather than throwing, so a fallback chains

tests/Integration/DocsExamplesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ public function testDateFormat(): void
244244
SmartString::$dateFormat = 'F jS, Y';
245245
$this->assertSame('May 15th, 2026', (string)$date->dateFormat());
246246

247-
$this->assertSame('2023-05-15', (string)SmartString::new(1684159800)->dateFormat('Y-m-d'));
247+
date_default_timezone_set('America/Vancouver'); // the docs show the timestamp example with T = PDT
248+
$this->assertSame('2023-05-15 PDT', (string)SmartString::new(1684159800)->dateFormat('Y-m-d T'));
248249

249250
$invalid = SmartString::new("not a date");
250251
$this->assertSame('Date not set', (string)$invalid->dateFormat()->or("Date not set"));

0 commit comments

Comments
 (0)