Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > mktime trouble
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 5th July 04:16
pt
External User
 
Posts: 1
Default mktime trouble



I'm taking a postgres timestamp from the database to something I can
parse with PHP (i.e., a unix timestamp. Thing is, the date function
isn't giving me the result I expect. Check this out:

print date ("m/d/y h:m:s A", mktime(16, 30, 0, 10, 10, 2003));

gives the output: 10/10/03 04:10:00 AM

Where did the 4:10 come from? It should be 4:*30*. To make things
stranger, when I change the month field in mktime to 9, like so:

print date ("m/d/y h:m:s A", mktime(16, 30, 0, 9, 10, 2003));

I get the output: 09/10/03 04:09:00 AM

It works the same way if I feed date a Unix timestamp, so I'm sure
this is a date problem. (using mktime in my example here is just
clearer than playing with unix timestamps).

date() and mktime() are usually simple enough, but something is going
wrong. Perhaps it is a dumb mistake on my part, but I'm not seeing
it....

peter


--
Peter Torraca
Webmaster, Math Department
Purdue Univ., Math 813
765-494-9998
  Reply With Quote


 


2 5th July 04:16
shiflett
External User
 
Posts: 1
Default mktime trouble



10 is the month, which is what the m means. Use i for minute:

http://www.php.net/date

Hope that helps.

Chris

=====
My Blog
http://shiflett.org/
HTTP Developer's Handbook
http://httphandbook.org/
RAMP Training Courses
http://www.nyphp.org/ramp
  Reply With Quote


 


3 5th July 12:08
sylvaing
External User
 
Posts: 1
Default mktime trouble


Your script should be

print date ("m/d/y h:i:s A", mktime(16, 30, 0, 10, 10, 2003));
print date ("m/d/y h:i:s A", mktime(16, 30, 0, 9, 10, 2003));

see the 'i' difference in (h:i:s)

your (h:m:s) is not right

With php date() fonction :
i = Minutes with leading zeros ex.: 00 to 59
m = Numeric representation of a month, with leading zeros

Sylvain Giroux
Solution Globale Informatique
http://www.solutionglobale.com
  Reply With Quote
Reply


Thread Tools
Display Modes




666