[pmwiki-devel] Help with PHP Dates

DaveG pmwiki at solidgone.com
Fri Jan 2 16:53:55 CST 2009

I've been struggling for a *long* time and basically getting nowhere. 
Hopefully someone can help.

For the scenario below a 'timestamp' refers to a date+time combination 
(i.e., 2009-01-29 23:54). I'm trying to perform these steps:
1] User enters a timestamp.
2] Make sure the timestamp is valid.
3] Store the timestamp as a PTV -- in some standard format.
4] Display the PTV is various user specified formats.

Basically, I'm having problems with [2] and big issues with [4], with 
some surprise at [3] ftime not being able to translate the Unix format.

1] I can do this bit :)

2] What I'd really like to do is to be able to check the timestamp, with 
any defined timestamp format -- seems like there is no 'easy' way to do 
this in PHP. Best way appears to be to stick to a single entry format, 
and use checkdate(), and then some regex for the time.

3] I initially thought to store using the Unix format. However, 
{(ftime)} doesn't appear to work when fed Unix timestamps. So, I'll use 
an ISO format '%Y-%m-%d %H:%M:%S'. This part works :)

4] Sounds like it should be easy to use {(ftime)}, but I'm not able to 
get a full time back using the default $TimeFmt ('%B %d, %Y, at %I:%M 
%p'). So:
input: {(ftime fmt="%B %d, %Y, at %I:%M %p" when="2009-01-22 16:01:00")}
output: "January 22, 2009, at 12:00 AM"

So, it looks like the fundamental issue the format I'm storing dates in. 
  What date format should I store dates with? Pm appears to recommend 
the ISO format, in archived messages.

  ~ ~ Dave

More information about the pmwiki-devel mailing list