0

I am using the following select statement to enter the a record in a cartodb database.

INSERT INTO catch (
  site_code, 
  have_catch, 
  fishtype1, 
  fishtype2, 
  fishtype3, 
  fishtype4, 
  fishtype5, 
  number_of_species, 
  **catch_date**, 
  fisherman_id
) 
VALUES (
 '$siteCode',      
 1,
 '$fishtype1',
 '$fishtype2',
 '$fishtype3',
 '$fishtype4',
 '$fishtype5', 
 $numbFish, 
 **now()**, 
 '$fishermanId'
); 

The catch_date, created_at and updated_at dates being written is a day ahead if the actual date. E.g. 2016-03-31 instead of 2016-03-30.

Any idea as to the cause?

This is a recent issue that seems to have started after I upgraded to the latest version of cartodb.js.

Also, the data is being written to a database in my cartodb cloud account.

I'm not sure as to the time zone.

3
  • 1
    In what time zone does your data exist? Does the local browser exist in a different time zone?
    – Vince
    Mar 31, 2016 at 3:45
  • @Vince The data is being collected in the Caribbean
    – ChrisJ
    Mar 31, 2016 at 10:28
  • 1
    Please edit the question in response to requests for clarification.
    – Vince
    Mar 31, 2016 at 10:50

2 Answers 2

2

Is it UTC?
Current UTC time: 3:41 AM Thursday, March 31, 2016
My local time: 8:41 PM Wednesday, March 30, 2016

Coordinated Universal Time (UTC)

0

Once you know in which time zone the data was collected (here you have a list of all the Caribbean time zones), you can update your date column with the following SQL query:

UPDATE TABLE_NAME
SET DATE_COLUMN = DATE_COLUMN AT TIME ZONE 'CODE'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.