I'm using the primefaces schedule component to create a schedule where the timezone is fixed to UTC. So, event times should appear in UTC no matter where the client browser happens to be, and no matter where the server is -- independent of any local time zone.
To do that I set both the timezone and clientTimezone attributes to "UTC".
That all appears to work fine in the displayed view.
I'm also using the lazy loading method where it fetches events from the server when the view changes. So, when I click on the "day" mode, I would expect that the fetch would retrieve events for the selected day, either from midnight to midnight, or maybe minTime to maxTime.
loadEvents now =2017-11-16 03:29:26 +0000 2017-11-16 03:29:26 +0000
loadEvents start=2017-11-15 04:00:00 +0000 2017-11-15 04:00:00 +0000
loadEvents end =2017-11-16 04:00:00 +0000 2017-11-16 04:00:00 +0000
Here, I opened schedule for default date (today), selected day view, and printed out the start/stop time parameters to the loadEvents call.
This shows that current day is nov 16, but the fetch starts at 04:00 the day before, and cuts off at 04:00. Local TZ is UTC-8 (Los Angeles), but I can't see how adding or subtracting that offset arrives at these values.
Is that how it's supposed to work?
I'm using primefaces 6.1.8 under java8/tomcat, jsf2.2
Related
I am using the DateTime-local in the HTML field to obtain the datetime from the users. I am sending the same to the backend which I am using to create the XML file. When I send the date to backend it subtracts itself by 2 hours for some reason.
I am not making any changes to it. I am currently in Central European Time (CET), I am guessing its changing automatically to UTC time because CET is 2 hours ahead of UTC. I am just curious to know whats happening here.
I am using the HTML, AngularJS and Nodejs for my project and following are my code samples:
HTML:
<input type="datetime-local" class="form-control" ng-model="formdata.EventTime">
For example, if I selected: 08 October 2020 12:30 PM then after the selection the field would appear something like this: 08/10/2020 12:30
In the AngularJS, just before making the HTTP POST request to my NODE.js I tried to console.log the time and it appeared something like this:
Thu Oct 08 2020 12:30:00 GMT+0200 (Central European Summer Time)
Now finally when I console.log in my Node.js then it appears something like this:
2020-10-08T10:30:00.000Z
I am just curious to know if this is some default functionality?
I could not find similar questions elsewhere so I am posting this.
There's a simple enough reason for the difference. The outputs of both are showing the same instant in time, however the AngularJS log is formatting the date in RFC 2822 format which shows the local timezone, while Node.js is logging the time in UTC formatted as an ISO 8601 time.
If you do this in both AngularJS and Node.js:
console.log(date.toISOString());
You'll get the same output (e.g.)
2020-10-08T10:30:00.000Z
Likewise if you try
console.log(date.toString());
You should get a similar output but in RFC 2822 format (e.g.)
Thu Oct 08 2020 12:30:00 GMT+0200 (Central European Summer Time)
Thanks, #Terry for the response. Based on his answer I did the following, I used the moment to convert my time from UTC to local. My project required me to retain the format of the date and syntax of it.
Install the moment library in Node.js.
When I was selecting 08/10/2020 15:30 in the datetime-local I was getting following date in Node.js:
2020-10-08T13:30:00.000Z
I tried converting it using:
EventTime = moment.utc(EventTime).local().format('YYYY-MM-DDTHH:mm:SS.sss');
Finally I got following output:
2020-10-08T15:30:00.000
I hope if someone else has the same doubt this might help.
I have been using primefaces 6.2.RC2 and in one of my pages I need to show a clock with seconds ticking every second for the set timezone. For this I have been trying to use p:clock as shown below. The problem I am seeing is that when my timezone is set to EST, it still shows CST time. Looks like the timezone attribute is not working with whatever values set:
<p:clock pattern="HH:mm:ss" mode="server" timeZone="#{loginBean.timezone}"/>
Even I have tried using f.convertDateTime and that is also not working for the <p:clock/>. Is there any solution to fix this issue?
Did you try America/New_York as the timezone? EST is UTC - 5 hours. America/New_York is EST in the winter and EDT in the summer, so right now New York is UTC - 4 hours.
CST = GMT-5
EST = GMT-5
EDT = GMT-4
America/New_York = -4 in summer and -5 in winter and switched on daylight savings.
I want to enable my button when the time comes 12:00 PM, because that was the data in my database, but I forget to open my program in 12:00 PM? The time passed to 2:00 PM and the button still needs to maintain the enabled status.
What is the query for that vb.net?
To satisfy this scenario, you have to change your time to a time range.
(Or just check if the current time equals or greater than the fixed time)
[12 PM - 3PM for example]
Whenever the applications is run, you have to initiate a method that will check the current time with your range. Based on it, you will enable or disable your button.
if(current time is in the given range)
yourButton.Enabled = True
else
yourButton.Enabled = False
So, it would not matter if you open your application at a later time.
I have a DateTime value stored in an SQL Server DB with a value like '2016-04-13 00:00:00.0000000'. My problem is that I want to display this value on a HTML page as is without the browser or my server adjusting for Time Zone offsets.
I make an Ajax request to get my data to an MVC controller. I can see that the value of the Date in my ViewModel is correct. When it gets to the browser depending on the machines timezone the Date is offset.
All I want is that if I have a value 2015-04-13 00:00 in my database then that exact value gets displayed on my interface regardless of timezones, locales etc.
My Ajax request returns a value like "/Date(1460502000000)/". I've tried the following conversions:
new Date(datavar);
Date(datevar)
new Date(parseInt(datevar.replace('/Date(', '')))
I've also tried using moment.js like the following:
moment.utc(datevar).format();
moment(datevar).tostring()
An several others all of which try to offset the date some way or other.
The suggested linked answer is different in that it will include the timezone offset. So a client on US Central Time a value of "/Date(1460505600000)/" will be converted to 'Tue Apr 12 2016 18:00 GMT-0500" while a client on GMT will get the same value converted to "Wed Apr 13 2016 00:00:00 GMT+0100"
I have a web page with a DatePicker control (from Kendo UI) on it.
Firstly, I'm in New Zealand, which is UTC +12:00
When I select a date of 31st October 2012 in my date picker, it gets stored in the JavaScript object as:
Wed Oct 31 00:00:00 UTC+1300 2012
This seems wrong!
It gets serialized to JSON (using JSON.stringify) as 2012-10-30T11:00:00.000Z, which is wrong.
Back on the server, when the JSON is parsed, this comes out at 30th October 2012, 23:00.
Can somebody explain this to me? And what is the solution?
I have this figured out now - the date picker control is working correctly, as for the date of October 31st, New Zealand will be in Daylight Savings Time, so at that date, we will be UTC +1300.
My problem is that my server code is converting to UTC on the basis of today's date, rather than using the offset as it would be on the the actual date.