I have written a node worker that gets instagrams and tweets and puts them into a database. It's on a heroku schedule that first checks to see if the todays date exists in the database, if it does then I overwrite it with the new data to make sure that day has no duplicate entries.
I'm setting the date with:
new Date(d).setHours(0, 0, 0, 0);
When I do this on my local machine I get todays date Nov 11th:
todays date 1447228800000
When I do this on heroku I get the day before Nov 10th and the hours and minutes are not 0:
todays date 1447200000000
So when I go to fetch the data for that day and try to display I am getting the day before. Does anyone know why this is happening?
Timezone, needed to update my timezone on heroku. This question is dumb.
Related
My end goal is to check subscription.cancel_at_period_end for false and store subscription end date as a moment date object.
const subscriptionEndDate = moment(subscription.current_period_end);
This is the result field coming from stripe in test mode.
current_period_end: 1649650039
But even using new Date(subscription.current_period_end) is coming back as 1970-01-20T02:14:10.039Z
Is this not the field that is suppose to show when the next billing date is ?
Any thoughts? What am I missing ?
UPDATE:
I was just doing some testing and figured out if I multiply that value by 1000 it comes out to be 1649650039000 which equates to
Mon 11 April 2022 00:07:19
Is there a reason for this? Is this a safe method moving forward?
UPDATE:
I accepted answer below and am providing momentjs that converts directly to unix timestamp.
const date = moment(new Date()).unix();
Issue
Stripe reports date fields as Unix timestamps. These represent a date/time as the number of seconds since January 1, 1970 (kinda...leap seconds are weird).
The Javascript Date object attempts to convert the number of milliseconds since January 1, 1970 as that is an increment of time that is more relevant to front-end web coding.
Solution
You have already discovered an adequate solution, that is multiply the timestamp by 1000 and thereby convert the value in seconds to a value in milliseconds. This appears to be a common work around 1, 2, 3
so everyday I receive sales data from the previous day. So today November 15 I have data from July 2021 until November 14 2021. What I want is to show this data for the current month by aggregating by day. I use a quicksight visual with a MTD (Month To Date) filter. Everything is fine so far.
The problem is on each first date of the month, I see "No Data" on my visual which is normal since I do not have any data from the current day/month but as I said earlier from the day before.
So what I want to achieve is:
Each 1st of current month: show data from the whole previous month
From 2nd to last day of current month: show data from the current month
Can someone help me please to know how I can achieve this?
I looked for ways to do this and I found dynamic default parameters but this option is not fine with me since I have to fill a username column according to the documentation (https://docs.aws.amazon.com/quicksight/latest/user/parameters-set-up.html) and I have many users so it will be not interesting to list all of them.
You can assign parameters to a group rather than a specific user which is much quicker
There is new functionality which allows you to set today or beginning/ending of month/quater/year as default.
See screenshot:
enter image description here
Our #flurry App Activity dashboard appears bugged. It only queries data from the first of every month, independent of the date range requested. Is this a known issue or recent bug? Everything was working fine just five days ago, and we haven't changed anything on the code side. Image of the current dashboard below:
Bugged App Activity Dashboard
Since you are looking at monthly data, Flurry pulls the whole month for any dates in your date range. Here it is showing all of August and September to date. If you want only September, you can change your dates to start September 1st. (Note that there is a time zone issue that can impact date selection, so you may need to change the first date to September 2nd in the date selector.) Alternatively, you could change your time grain to weekly or daily. Feel free to contact support#flurry.com if you'd like more assistance.
I want to get today's date in SuiteScript, when I type var tDate = new Date(); it shows me yesterday's date while debugging. I checked settings, there I couldn't see anything wrongly.
I am editing to this question. Most confusing thing is sometimes new Date () shows correct Date without any changes. No idea why it's acting like this. I added result of 'new Date()' as a picture right below.
In the first picture I captured on 1st of February, that shows me 31st of January which is wrong
In the second picture I captured today, that shows me today's date which is correct.
new Date() will give you the current timestamp according to the timezone of whatever system is running the code. In your browser console, new Date will give you the current timestamp in local time; in a server-side script, new Date will give you the current timestamp according to the timezone of your NetSuite data center.
How are you running this code, and what timezone are you yourself in?
I'm using Node.js, Postgres, and the node-postgres library. When I try to insert a new record with the current date with code like this:
client.query('INSERT INTO ideas(date) VALUES($1)', [new Date()], ...);
And this runs fine with no errors. However, when I run a select statement against the database and log the results, the date I'm given appears as:
Wed Nov 20 2013 19:00:00 GMT-0500 (EST)
Which is fine, except that when I inserted the record, it was Thursday, November 21. And the time was 5:47, not 7:00 as the output would suggest.
I ran the code a few more times, and it stored the same inaccurate date no matter the time, even once the next hour had begun. This leads me to believe that for some reason, it's only storing the date and not the hour or minute. In addition, the fact that the date is only off by one day suggests that the problem might have something to do with the way node-postgres handles dates.
I know it's not a problem with Javascript calculating the current date when passing it into the query, because I logged new Date() and it was accurate, to the date, minute, hour, and second.
Any help on this issue would be greatly appreciated. Thanks!
The problem (thanks to Craig for pointing this out) was that I was using the date type for my Postgres column, which only records dates, and not times. Once I switched to the timestamptz type everything worked perfectly!