Strange behavior with created date - datetime

I have something strange with time of created objects.
I'm in france, and the server time is ok.
When I create a new document at 09:45, I have thoses data in the catalog :
Date 2012-07-13T07:45:01+00:00
ModificationDate 2012-07-13T07:45:01+00:00
created 2012/07/13 05:44:37.933325 GMT
modified 2012/07/13 05:45:1.990650 GMT
CreationDate 2012-07-13T07:44:37+00:00
created and modified are 4 hours before !
Is there a way to fix the timezone or something to correct that ?

Related

Firebase Realtime Database, synchronized with Google sheet, accepts wrong Date from Datepicker sheet cell

How Google Sheet looks
How Firebase Database looks
So the date keeps saving as the day before date;
At Google script appsscript.json is set my real timezone:
"timeZone": "Europe/Kiev"
Any suggestions?
It sounds like the two timestamp values actually refer to the same moment in time. Firebase timestamps are always in UTC.
2021-05-16 00:00 GMT+3 refers to the same point in time as 2021-05-15 21:00 GMT+0. The timezone difference between Kiev and GMT is two hours + one hour because of daylight saving time, so during EEST the two serialized values will look like they are three hours apart.
You can deal with the timezone difference in the client, displaying the timestamp value you retrieve from Firebase in the local time of the client. If the client is in the Kiev timezone, the value will then look the same as it was in the Google Sheet originally.
If you want to save the date as a static text string instead of as a Date object, you may want to convert it in Apps Script with const timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone() and const dateString = Utilities.formatDate(myDate, timezone, "yyyy-MM-dd"), or in JavaScript with the Intl object or a library like moment.js.

convert pubDate to timestamp rss in yql

I have a YQL query where I am accessing data from an RSS feed. I want to get the pubDate for the articles in the feed, but I don't want it to be in (for example) this format:
Fri, 30 Nov 2012 14:19:55 +0000
I would prefer it to be in this format:
11/30/2012
Is there a simple function within YQL itself that would let me do this? Just to be clear, I would prefer to have a YQL-only solution, without having to use PHP or javascript or anything.
Check this link. In particular look at y.date.getOffsetFromEpochInMillis(time_format) function. This gives you the epoch in milliseconds.
After you get that, inside your YQL open data table definition, massage this timestamp to mm/dd/yyyy format as listed in the question Convert a Unix timestamp to time in JavaScript

How do I get the date AND TIME to show up in a Crystal report?

I'm working with Crystal Reports for Visual Studio 2010. The data is in a SQL Server 2005 database. The field is a datetime field, within the database/table. It has both date and time in it. But my report refuses to see that field as anything other than a date field. Huh??? According to this article on C# Corner, there should be a Date, a Time and a Date And Time tab when customizing the display. No there isn't; the only data type tab I see, when I try to customize it, is Date.
So, how do I get the date and time to show up from a datetime field returned by the stored procedure, when CR for VS 2010 only wants to treat it as a Date field???
We finally found the solution. The report I'm working with is really old. It was started by someone over 10 years ago, using who knows what version of Crystal Reports was around then. My colleague decided to start a whole new report and drag the field first from the table, and then from the stored procedure that's used for the report, onto the new report. Well, the data type was now DateTime! The best we can figure is the original .rpt file must not have had a DateTime data type (that field in the table has been a DateTime for 15+ years). We even discovered that creating a new report based upon this existing report, doesn't resolve the issue; it still sees the field as a Date data type only. So we've got to create a new report and start over from stratch. Frankly, pretty awful to do, just for 1 field in the report, but oh well.
This shows you how to set CR to set how it interprets DateTime as either Date or DateTime:
SAP Community Network Issue

Drupal Date api, dates are displayed as one day earlier than the date entered

i'm not sure what is going wrong, but I created a Date field, and though it has been working fine, on March 12, 2012 and beyond all dates entered are retrieved one day earlier. The fields in the node edit display the correct date, but retrieving is the problem. I'm not sure if it is a timezone issue? Why March 12, 2012 and past that?
I have a feeling it has something to do with UTC and DST, but i dont know what to do. In the Date and Time settings I have it set as america/toronto which is what I want.
I just added the timezone when using the format_date function:
$date_start = format_date(strtotime($node->field_event_date[0][value]),$type='custom',$format='F j, Y',$timezone='America/Toronto');

how to store datetime as per internationalization

I am having a project which will have country dropdown at the top to select countries. For example USA, India and Hong Kong. Depends on the country selection several features will be enabled or disabled.
In project I am having base country by default for example India. So whenever any user will come. I want to store its login datetime as per Indian standard time regardless user is from Hong Kong, USA or India. My webserver is hosted in USA.
Is that possible?
What you want to do is store any datetime value as UTC. Which means storing as a time zone independent value.
You can either set some sort of insert trigger in your MS-SQL server (I assume you use MS-SQL because of the asp.net part). There you determine the UTC time like this.
`-- MS SQL (use instead of GETDATE())
DECLARE #currentTime datetime
SET #currentTime = GETUTCDATE()`
If you want to do it in code just use UtcTimeNow to access the UTC time.
// C# (use instead of DateTime.Now)
DateTime currentTime = DateTime.UtcNow;
If you want you can always convert the UTC time to any given local time. By using the TimeZoneInfo class.
That way you have the right time in your database (UTC) and can convert it to the appropriate time for the User.
The most important part when dealing with times and timezones is to store it as UTC. That way it's can be transported and compared easily.
If you save your time in unixtime, you can have a field in the user table called offset. Where it's value is how much the system needs to offset the time.
Then you'd just fetch that variable and save that as a session value or something similar. And use that to offset the datetime in the system.
For example. Hong Kong is +8 hours from GMT. Now in GMT Unixtime is: 1242293400 (9:30 am). 8 hours is 28800 seconds. You would then store this value in your server. So the time would be 1242322200 (5:30 pm same day)
IF you are using SQL Server 2008, look at the new datetime datatypes which allow you to store the offset/timezone as well.

Resources