Jump to content
Larry Ullman's Book Forums

Auction - Items That Have Closed


Recommended Posts

Hi Larry,

 

After quite a bit of delay, I have been working through the book - great!!

 

I have managed to get both the non-AJAX and AJAX auction sites working but have a question re closed bids (page 567).

 

The index script only lists open auctions, so, without fiddling, how does one get the 'auction closed' message?

 

Thanks, Necuima.

Link to comment
Share on other sites

Hi Larry,

 

OK, I have modified the query and also put in a crude test to change the 'closes' heading message to 'closed' if the auction close date/time has passed. I'm not particularly happy with my 'crude' test but it seems to work OK.

 

I need to do some more study to better understand the UTC date-time / local date-time approach (which makes good sense in this context) and how to code for it appropriately!

 

Thanks again for a great book!

 

Cheers from Oz.

Link to comment
Share on other sites

Hi Larry,

 

I have been experimenting with PHP and dates and have the following query:

 

If I code: $utc = strtotime(gmdate("Y-m-d H:i:s")); I get a Unix timestamp for UTC.

 

But if I code: $utcU = gmdate("U"); I get a Unix timestamp for my local time zone.

 

I am obviously mis-understanding gmdate with the "U" parameter. I thought that gmdate returns UTC and that the "U" parameter gives you a Unix timetstamp.

 

Can you please help me understand this?

 

Thanks, and cheers.

Link to comment
Share on other sites

Hi Larry,

 

I tried: $utcU = gmmktime();

 

but it returns the timestamp for my timezone, not GMT/UTC?

 

I can't see where/if a parameter needs to be supplied to indicate that I'm wanting GMT/UTC?

 

To make my question clear, I am looking for the current UTC/GMT time, i.e., the GMT/UTC UNIX timestamp for the time at which I run the script.

 

Again, any advice will be appreciated.

 

Thanks, Necuima.

Link to comment
Share on other sites

Hi Larry,

 

It is not a silly question at all - in fact I have been pondering this in some depth over the last few days.

 

Here's my logic:

1) I do gmdate("Y-m-d H:i:s") and then print it out and it is indeed UTC/GMT.

2) I parse out the values and then do $utcxx = mktime($hour, $min, $sec, $mm, $dd, $yr) (page 114 of your PHP & MySQL book 2nd edition)

3) I var_dump $utcxx and it gives me a timestamp.

4) I then do $utcU = gmmktime() and then var_dump it out and it gives me a different timestamp.

5) I then subtract the step 2 timestamp value from the step 4 timestamp value, divide by 3600, and it gives the correct time differential between my time zone and UTC (+10 hours).

 

Thus I conclude that the gmmktime function gives me a timestamp value for my location, not GMT/UTC.

 

Am I going nuts??

 

Thanks, Necuima.

Link to comment
Share on other sites

Learning something new...I just tested this myself and gmmktime() and mktime() were returning the same values when called with no arguments. I read through the user comments on the gmmktime() and someone pointed out that this is the case. However, if you proved any arguments, such as just the hour, it works:

echo (gmmktime(14) - mktime(14)) / 3600;

Link to comment
Share on other sites

Hi Larry,

 

Thanks for checking this out. I was wondering if I was going a bit crazy!!

 

I have tried putting an hour (an integer) in gmmktime and it gives varying results depending on what integer you use and what time of day you run the script.

 

Your echo above works just fine for the time differential, but the gmmktime(n) function on its own will not give you a timestamp for GMT unless you use the correct value for 'n', and that value is not the time differential between your time zone and GMT (well it may be for one particular hour of the day).

 

Weird eh!

 

I suggest that we close this thread. From my tinkering about I can reliably get the timestamp for GMT/UTC via the code in an earlier post.

 

Thank you for your interest.

 

Best regards from Oz.

Link to comment
Share on other sites

 Share

×
×
  • Create New...