How to get previous month values in UTC in Javascript - javascript

I need to use jquery flot plugin to plot time based data on a graph in a web page. It needs time parameters to be passed in UTC format. Getting current date is quite easy just defining a Date Object help. But i also want the UTC value for last six months from current date how to get that in JS..?

Have a look at link : Jquery Date

Related

unable to display a single year using #nivo/calendar

I'd like to leverage #nivo/calendar to display a year's worth of data (every single day of the year). All my dates are within the valid range. If I set the start date to 2016-01-01 (where YYY-MM-DD), I get two year calendars (2015+2016). Setting it to 2016-01-02 fixes the issue (shows only 2016), but then I missing data for the first day of the year. I have a hunch this is some sort of timezone bug.
Has anyone run into this issue?
from="2016-01-02" // setting from to 2016-01-01 causes bug where two years are shown instead of one
to="2016-12-31"
You can see the issue here:
https://codesandbox.io/s/nivo-calendar-single-year-forked-lemu8i

Jquery input mask to input date range

I am making a web app which should accept a specific interval that is added to the target date to check if the request is expired. So I need an input with formatting: months:days:hours
Where months is limited to 12, days to 31, and hours to 24. I tried to use jQuery inputmask plugin
I made like this:
https://jsfiddle.net/qahxvspb/2/
But it doesn't work for some reason, I put a mask like this:
mask: "mm-dd-hh"
But in the input I get weird stuff, there is still placeholder mm-dd-yyyy, and I only can input year into it.
So 2 questions:
How to make a correct mask?
How can I make allow zero month in the mask? So, basically, it would be optional for the range, if I want I would just put 0 into month, check that on server, and create a range only from days and hours.
Javascript Date makes my head hurt because of things like what you are trying to do
I use a library called moment,which is available as a cdn or npm package
It can create input patterns like the one you have, do arithmetic on dates and then convert to the time format you want, even Javascript Date

How to fix my date values from changing when exporting from database

I am trying to create a time sheet database which records the date and time a user clocks in and clocks out I have set up my Postgresql table and have it display through react correctly however when I export the data to Excel the time in the date value moves 4 hours behind and shifts the day to one day before. How can I fix this?
I have already tried using different data types such as date, timestamp and timestamptz however all of them end up giving me the same outcome.
My current punch in Date column for SQL looks like:
ADD COLUMN in_date timestamp without time zone NOT NULL DEFAULT CURRENT_DATE;
The table displayed on my web app screen will show the date 2019-05-08 00:00:00
However when I export to Excel the same column shows 2019-05-07 8:00PM.
I know that the values are being set back 4 hours due to timezone change from UTC to my Local time however I am not sure how to fix this. I have tried a lot. Any suggestions would be greatly appreciated.

How could I get the date in jQuery through timezone

I have a code that calculates next Monday and sends a link to the user, however if the user advances the calendar, receives the video before everyone else.
How could I get the date in jQuery through timezone, without giving the user the chance to change the date on the computer and cheat everything?
Not sure if I understand the question but if you just want the current date through jQuery you can use:
$.datepicker.formatDate('yy/mm/dd', new Date());
Note: you will need jQuery UI for this.

How to show calender date based on users location using javascript

Actually i want to show the user's local date in the calender using jquery datepicker. By default, the calender is showing the Brisbane, Australia time. But i want to show the date based on the user comes from the location. Like if the user is coming from US, Europe, UAE, UK etc then i have to show these locations. Is there any solution available in Javascript? Please help me out.
Thanks.
Try using
Date().toLocaleString()
But this will only work if your date is stored in ISO or UTC format or you date is GMT.
If not then you will have to convert it into unix-time and then parse it.
You can do it by combining your code with php. Here get timezone from user and save that in one variable. After then code as below:
$UtimeZ = usertimezone;
date_default_timezone_set('$UtimeZ');
$UserDateTime = date('Y-m-d H-i-s');
Now show that date in calender using javascript.

Categories