Jump to content



Latest News: (loading..)

- - - - -

Happy Hours Specials Basic - problem with time zones


This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1   bigbob2

bigbob2
  • Members
  • 117 posts

Posted 11 December 2011 - 08:54 AM

I have installed a contribution called Happy Hours Specials Basic.  I have posted tho question below on the forum page for that contribution, but it was last posted on in 2006, so I am trying here too as I think this question is generic regarding Time Zones.

I need to know where OsCommerce gets the time and date from generically?  I have installed the above contribution and it is not working correctly.  Int eh contribution you set a time and date for a special to be active, but I am in New Zealand, but our site is hosted in the US. I made a page for the specials to show on and in that page I put:

date_default_timezone_set( 'Pacific/Auckland' );

The specials show at the right date and time on that page using our local time, but when I add to cart, or click on the product page, (product_info.php) the special price does not show, because the time in the US is 12 hours behind ours. If I set the specials times to 12 hours out then they add to cart with the right price, but then they are out on my new page, because we are 12 hours ahead!

Please help and let me know where it gets the date from, so I can pop in my time zone.

Thanks
Kevin

#2   jpweber

jpweber
  • Members
  • 1,259 posts

Posted 11 December 2011 - 01:34 PM

Are you in a different time zone from where your server is hosting your site?  If so, something like this will work:
http://www.oscommerce.com/community/contributions,4156
If that doesn't work, you can go to (path to catalog)/includes/languages/english.php and find this line:
@setlocale(LC_TIME, 'en_US.ISO_8859-1');

And consider changing to this:
@setlocale(LC_TIME, 'ge_GE.ISO_8859-1');

See how these things work.  Hope it helps.
Jason

Simple 1-2-3 Intructions on how to get, install and configure SSL

The Google Sandbox explained

Simple to follow instructions on how to change the look of your OSC

How To Make A Horrible OSC Website

my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor

my installed contributions:  Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout,  Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...

#3   MrPhil

MrPhil
  • Members
  • 4,127 posts

Posted 11 December 2011 - 05:57 PM

Are you kidding? That sets the language and the formatting of the date and time, not the timezone itself. What would happen if you give en_US for a site in the U.S. -- which of many timezones (6 or 7, plus territories) would it use?

Try putting date_default_timezone_set( 'Pacific/Auckland' ); in application_top.php, so it kicks in on every page.

This assumes the OP is at PHP 5.1 or higher.

Edited by MrPhil, 11 December 2011 - 05:59 PM.


#4   bigbob2

bigbob2
  • Members
  • 117 posts

Posted 11 December 2011 - 06:32 PM

View PostMrPhil, on 11 December 2011 - 05:57 PM, said:

Try putting date_default_timezone_set( 'Pacific/Auckland' ); in application_top.php, so it kicks in on every page.
This assumes the OP is at PHP 5.1 or higher.

I actually tried that already and it did not make any difference.

Any other ideas?'

Kev

#5   germ

germ
  • Members
  • 13,921 posts

Posted 11 December 2011 - 08:06 PM

From the PHP manual you'll find a list of Australian time zones that function supports here

Maybe one of them will suit your location and actually work for you.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#6   MrPhil

MrPhil
  • Members
  • 4,127 posts

Posted 11 December 2011 - 08:47 PM

Don't tell a Kiwi that they're in Oz! That's like telling a Canadian that they're really an American. "Pacific/Auckland" should be a valid timezone. Is the OP on at least PHP 5.1?

#7   germ

germ
  • Members
  • 13,921 posts

Posted 11 December 2011 - 08:56 PM

Full list of supported time zones
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#8   germ

germ
  • Members
  • 13,921 posts

Posted 11 December 2011 - 10:07 PM

If you can't adjust the time via setting the time zone you can adjust the time with the code like this.

Old code (from the contribution):

  $date = date ('Y-m-d');
  $time = date ('H:i:s');

New code:

  $my_local_time = time() - (12 * 60 * 60); // server time - 12 hours
  $date = date ('Y-m-d', $my_local_time );
  $time = date ('H:i:s', $my_local_time );

It may not be the ideal solution but it does work (I tested it).

And my sincerest apologies if I've offended anyone by erroneously thinking Aukland was part of Australia.

I haven't had a geography lesson in several decades...
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#9   bigbob2

bigbob2
  • Members
  • 117 posts

Posted 12 December 2011 - 01:06 AM

Hahaha thanks guys, I will try it out.  If your help fixes this code for me, you can call me anything you like :)

Cheers
Kev

Edited by bigbob2, 12 December 2011 - 01:13 AM.


#10   bigbob2

bigbob2
  • Members
  • 117 posts

Posted 12 December 2011 - 01:13 AM

Jim, what page on the contribution we you referring to the following being in:


  $date = date ('Y-m-d');
  $time = date ('H:i:s');


Cheers
Kev

#11   germ

germ
  • Members
  • 13,921 posts

Posted 12 December 2011 - 01:19 AM

The contribution I downloaded only had one page/file: happy_hours_specials_basic.php
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#12   MrPhil

MrPhil
  • Members
  • 4,127 posts

Posted 12 December 2011 - 03:29 PM

Any place that date() is being called, you are to replace the default "time()" with a time() that has had a seconds offset added. If the U.S. server is showing 12 hours behind you, you would want to add 12 * 3600 seconds to time(), and use that time instead of the default. The actual time() is GMT (UTC), and the server configuration will add/subtract a fixed offset to get to your U.S. server's timezone and DST rules when formatting using calls such as date(). The change is to kludge this to add another 12 hours. It would be far better to set the appropriate PHP timezone, but if you're not on PHP 5.1.0 or higher it doesn't work.