Forums / Contribution-Writing Guidelines / date problems inserting amazonpayments orders into database

date problems inserting amazonpayments orders into database

Locked

Started by amazonpayments on 27 Aug 2010, 7:21 AM · Views: 5,291

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
27 Aug 2010, 7:21 AM
#1
amazonpayments avatar

amazonpayments

New Zenner

Join Date:
Oct 2009
Posts:
52
Plugin Contributions:
0

date problems inserting amazonpayments orders into database

Hi all,

I am creating the order using the order classes available in zencart. when creating the order, i used to pass 'now()' for date_purchase field in $order->info so that purchase date is updated.

but it seems that it is not working or it is throwing a date* 11/30/1999 00:00:00*

what is the best way to pass the date? should i just pass the gmdate() string?

27 Aug 2010, 7:35 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: date problems inserting amazonpayments orders into database

now() is correct and uses the database server's date/time. If it's not storing correctly, then you've got something amuck with your database. If it's not displaying correctly, then you've likely got something amuck with your date formats.

You shouldn't have to duplicate a whole lot of code to create orders. Best to simply invoke the built-in orders class and use its methods to do the real work. Any other duplication of code that you do will just make more work for you to maintain and great headaches for the merchants using your code.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Aug 2010, 7:41 AM
#3
amazonpayments avatar

amazonpayments

New Zenner

Join Date:
Oct 2009
Posts:
52
Plugin Contributions:
0

Re: date problems inserting amazonpayments orders into database

DrByte:

now() is correct and uses the database server's date/time. If it's not storing correctly, then you've got something amuck with your database. If it's not displaying correctly, then you've likely got something amuck with your date formats.

You shouldn't have to duplicate a whole lot of code to create orders. Best to simply invoke the built-in orders class and use its methods to do the real work. Any other duplication of code that you do will just make more work for you to maintain and great headaches for the merchants using your code.

somehow that now() isnt working. i parsed the date from the order report from amazon which has some thing like ```
<OrderDate>2009-11-26T12:48:18.000Z</OrderDate>

but there will be a timezone issue. the above date is PDT. 

In zencart, how can i find the timezone that the site uses for all orders and convert the time reported to the site's time zone so that all orders from Amazon are consistent with orders from other payment gateways.

- Bala
27 Aug 2010, 7:43 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: date problems inserting amazonpayments orders into database

"2009-11-26T12:48:18.000Z" is not in "YYYY-MM-DD HH:MM:SS" format which MySQL uses. If you're sending the date as 2009-11-26T12:48:18.000Z then I'm not surprised that it's converting it to something else.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Aug 2010, 7:44 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: date problems inserting amazonpayments orders into database

AmazonPayments:

In zencart, how can i find the timezone that the site uses for all orders and convert the time reported to the site's time zone so that all orders from Amazon are consistent with orders from other payment gateways.
Zen Cart v1.x does nothing special with timezones. It simply relies on the date/time of the server on which it is running.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Aug 2010, 7:48 AM
#6
amazonpayments avatar

amazonpayments

New Zenner

Join Date:
Oct 2009
Posts:
52
Plugin Contributions:
0

Re: date problems inserting amazonpayments orders into database

DrByte:

"2009-11-26T12:48:18.000Z" is not in "YYYY-MM-DD HH:MM:SS" format which MySQL uses. If you're sending the date as 2009-11-26T12:48:18.000Z then I'm not surprised that it's converting it to something else.

I parse the date and send it in a mysql supported format as you suggested. it works after sending it in that way.

my concern is the time. I send the date time as 2009-11-26 12:48:18 which is from the order report. That time is a PDT one. what if a merchant hosted his store in which PDT is default?

In that case, i have to convert them to the desired timezone where the store is located. any idea on how to do it?

  • Bala
27 Aug 2010, 7:50 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: date problems inserting amazonpayments orders into database

Write something in one of the files you've got on the store's server, asking it what the time is. Calculate the difference from yours, and send the results accordingly.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Aug 2010, 7:56 AM
#8
amazonpayments avatar

amazonpayments

New Zenner

Join Date:
Oct 2009
Posts:
52
Plugin Contributions:
0

Re: date problems inserting amazonpayments orders into database

DrByte:

Write something in one of the files you've got on the store's server, asking it what the time is. Calculate the difference from yours, and send the results accordingly.

Thank you DrByte. i will try to fix it.

27 Aug 2010, 9:11 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: date problems inserting amazonpayments orders into database

Your posts containing fixes have been moved to their own thread: http://www.zen-cart.com/forum/showthread.php?p=927552#post927552

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.