admin管理员组文章数量:1316356
I want to make a weblog that has with every date 1 or more weblog posts, e.g.:
Januari 24 Year 41 : Roman Emperor Caligula was murdered by Cassius Chaerea and the disgruntled Praetorian Guards. Caligula's uncle Claudius was proclaimed emperor in his place.
or
Januari 1 Year 153 BC : Roman consuls begin their year in office.
or
Februari 1 Year 2038 : Humans survived
What would be the best way to do this in WordPress if I want to support URL hacking?
p.s. custom fields + custom posts + custom taxonomy was the first thing I thought of but maybe there are better alternatives relying on the current date system.
related:
I want to make a weblog that has with every date 1 or more weblog posts, e.g.:
Januari 24 Year 41 : Roman Emperor Caligula was murdered by Cassius Chaerea and the disgruntled Praetorian Guards. Caligula's uncle Claudius was proclaimed emperor in his place.
or
Januari 1 Year 153 BC : Roman consuls begin their year in office.
or
Februari 1 Year 2038 : Humans survived
What would be the best way to do this in WordPress if I want to support URL hacking?
p.s. custom fields + custom posts + custom taxonomy was the first thing I thought of but maybe there are better alternatives relying on the current date system.
related: http://en.wikipedia/wiki/Unix_time#Representing_the_number
Share Improve this question edited Jan 24, 2011 at 16:41 edelwater asked Jan 24, 2011 at 16:27 edelwateredelwater 2,58419 silver badges33 bronze badges2 Answers
Reset to default 2Unix time is defined as the amount of seconds since the "Unix epoch," which is 00:00:00 UTC on 1 January 1970.
It works both forwards and backwards -- so technically you shouldn't have trouble representing dates all the way back to Jan. 1, year 1, but the numbers would be negative and extremely large.
EDIT: PHP appears not to be able to handle those dates easily, at least according to one basic test. Both echo $time = strtotime("January 1, 1");
and echo $time = strtotime("January 1, 0001");
result in 978325200
.
I think the best option is, as you muse, categories. Whether or not you want to deal with custom categories might be a matter of preference, but I suspect normal categories with the names you lay out would work just fine.
Not sure about WordPress specifics on processing date when saving post, but it stores post's date in database under datetime
type, which according to MySQL The DATETIME, DATE, and TIMESTAMP Types only has range of 1000-01-01 00:00:00 to 9999-12-31 23:59:59 and so won't go back as far as you want.
So it is definitely better to store date separately (custom field makes sense) as string or timestamp.
Also strtotime()
is usually awesome, but has limitations of its own:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.
Overall I suspect that for such extreme dates you will need to write your own code or find some ready-made by third party.
本文标签: What is the best workaround for supporting all existing DATEs
版权声明:本文标题:What is the best workaround for supporting all existing DATEs? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742002468a2411290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论