Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: changing image Date added
The main reason we use intl is i18n, since strftime() is deprecated, and date() is English only. As long as only numeric values are present in a date format, we go with date(), which looks pre-Gregorian consistent. But for more localised formats, intl seems unavoidable.
It might be feasible to integrate a switch from Gregorian to Julian calendar for pre-1582 dates, but is it really worth doing? BC era wouldn’t fit into datetime db type anyway.
Offline
Re: changing image Date added
Let’s stick with what we have. If anyone is using pre-Gregorian dates, well, they’ll have to add the calendar attribute to their tags, right?
<txp:date type="image" calendar="julian" ... />
Edit: ugh that’s fine for front side but this is back-end isn’t it. Ignore me. It’s late.
Last edited by Bloke (2025-11-16 23:50:26)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: changing image Date added
A brief test (PHP 8.4): In the images panel, all work as expected. There is a 9 hours difference between the Textpattern time (preference time zone set to UTC) and the MySQL DB time (set to OS time – JPN standard. UTC – 9).
One thing I noted, but perhaps that is not yet fully implemented: I post 3 images in an article (in a <txp:images id="1,2,3" "sort=date asc" /> container), including: Date: <time datetime="<txp:image_date format="iso8601" />"> <txp:image_date /> </time> below the image.
An image dated 2025-09-14 outputs the correct date & time, and so does an image dated 1978-11-09 (timestamp: 1978-11-09T14:22:01+0000, 09 November 1978, 14:22), but the image dated 1925-09-22 15:23:11 (DB time, UTC -9) outputs 01 January 1970, 00:32 (iso8601: 1970-01-01T00:32:05+0000).
Sorting works OK.
But the article date stamps (<txp:posted /> and <txp:modified />) seem wrong (an offset of 18hours behind the real time)?
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: changing image Date added
phiw13 wrote #341210:
… but the image dated 1925-09-22 15:23:11 (DB time, UTC -9) outputs
01 January 1970, 00:32(iso8601:1970-01-01T00:32:05+0000).
Thanks for testing, this issue should be fixed now.
But the article date stamps (
<txp:posted />and<txp:modified />) seem wrong (an offset of 18hours behind the real time)?
This one is amazing, as if the -9 hours offset were applied twice. There are 3 time zones in play:
- php server time zone
- db server time zone
- txp pref time zone
The dates should correspond to the latter, but things can get complicated if the php server does not support all time zones. What does this output for you:
<txp:php>dmp(date_default_timezone_get(), tz_offset());</txp:php>
Offline
Re: changing image Date added
etc wrote #341211:
Thanks for testing, this issue should be fixed now. That would e very valuable addition to Textpattern I think.
Yes! Now that looks nice across the board I think.
This one is amazing, as if the -9 hours offset were applied twice. There are 3 time zones in play:
- php server time zone
- db server time zone
- txp pref time zone
The dates should correspond to the latter, but things can get complicated if the php server does not support all time zones. What does this output for you:
<txp:php>dmp(date_default_timezone_get(), tz_offset());</txp:php>…
UTC
0
Quick test: As soon as I set the TXP pref to Tokyo instead of UTC then article dates are correct – both 4.9rc2 basic install and a 5.0-dev basic install (both have the very minimal configuration).
On two live servers, Singapore and Hong Kong based (UTC-8) the TXP (4.9) pref is set to “Tokyo” with no errors.
The local server php.ini has date.timezone = Asia/Tokyo.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: changing image Date added
phiw13 wrote #341213:
Quick test: As soon as I set the TXP pref to
Tokyoinstead of UTC then article dates are correct – both 4.9rc2 basic install and a 5.0-dev basic install (both have the very minimal configuration).
You mean the dates are correct in Tokyo time? Then, when the pref was set to UTC, they were correct (-9 hours) in UTC time, or the offset was double?
Offline
Re: changing image Date added
etc wrote #341214:
You mean the dates are correct in Tokyo time? Then, when the pref was set to
UTC, they were correct (-9 hours) in UTC time, or the offset was double?
When the pref is set to UTC, the offset is indeed double. Date on my local computer: November 17, 17:10:xx (UTC -9), Date displayed on the Write tab, or on the public view of the article (<txp:posted />): November 16 23:10:xx.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Offline
Re: changing image Date added
etc wrote #341216:
Weird. And what is its db
datetimevalue?
For UTC: shown as UTC time (9 hours off)
I played a little with a TXP-4.9RC. If I set the time zone pref to Paris (UTC-1), everything works fine. The DB datetime is shown as Japan time, Posted and Modified dates are the correct Paris time.
Then Hong Kong or Singapore (UTC-8). The DB time is one hour off (10am is shown as 9am), the Posted and Modified dates are 2 hours off, shown as 8am, double conversion.
Trying the same on a live test site, Singapore server. All work correctly (Paris / Singapore / Tokyo time zone). Database server time is set to UTC (SYSTEM according to diagnostics).
Local server uses PHP 8.4, Singapore server uses PHP 8.3.
It is odd as locally the date as shown on the pref pane (date format, Archived date format) are always correct.
I’ve no idea if that is a local issue (server config? database config?), or a PHP 8.4 issue.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: changing image Date added
That is odd. To diagnose this fully, we also need to know the value of the image’s date field in the database column itself, directly from the txp_image table.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: changing image Date added
Bloke wrote #341227:
That is odd. To diagnose this fully, we also need to know the value of the image’s
datefield in the database column itself, directly from the txp_image table.
The image date field inside the txp_image table is always correct, matches what Textpattern outputs on public and admin side (taking into account different timezones between database and Textpattern). I was talking about the article date fields.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: changing image Date added
Gotcha, thanks. Mine’s different, for some reason. If I enter the date and time in the Images panel, what’s actually stored is the timestamp an hour later. And that’s the same if I do it on a live site (server in Germany) or on localhost.
So the fact your DB timestamp is the same as what you stored indicates some other settings that affects how the date is stored – likely your server or connection being UTC, where mine is something else.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline