KeystoneJS Datetime format in Admin UI - keystonejs

How to disable the AM/PM in Datetime field in Admin UI (enable 24 hour clock)?
The momentjs format strings doesn't seem to affect it in any way.

Related

How to convert Firestore Timestamp UTC to UTC+1 in React-Native using Moment?

I want to use MomentJs to convert Firestore Timestamp (which is by Default UTC) to UTC+1. How can I do that?
firestore.Timestamp.now().toDate()
P.S. I dont want to use the local/device's time.
Firestore Timestamp (which is by Default UTC)
There is no "default" really. When you have a Timestamp object (or a JavaScript Date, or any other native date object from a modern operating system), the moment in time is always represented internally in UTC.
When you call toDate() on a timestamp, the resulting Date is still internally represented in UTC.
Don't be confused about the "default" string representation of a Date object. It will appear in the local timezone where the computer's operation system is configured. But internally, it's still UTC.
If you want to format the timestamp as a string for another timezone, you can certainly do that. momentjs has an accompanying library Moment Timezone that can help you with that. The momentjs library itself will not help you with timezones (other than the one provided by the local of the system where it is running), as it's generally understood that native timestamps are always UTC.

Google Data Studio Date Issue

I'm trying to generate report from Google Data Studio where i am using BigQuery As Connector, i want to change my Time Zone As per My Location (Current Time and date) but not as per BigQuery Time zone,
is there any Chance do this in Google Data Studio.
You can use something like
DATE(timestamp,"Asia/Kolkata") as Timestamp
or
You can use Bigquery, the 2nd argument of the TIMESTAMP() function to convert UTC timestamp to your local time zone
SELECT TIMESTAMP("2020-02-24 13:30:00", "Asia/Kolkata") AS timestamp_in_IST;
Here is the supported timezone by Big query
The functionality (Time Zone calculations) is now available in Google Data Studio, with the introduction of additional Date Time functions in the 17 Sep 2020 Update. Using Mohit's example; where the goal is to convert the Date Time field (titled Date_Field in this Report) from the default (UTC) to Asia/Kolkata (change the Time Zone as required), the following does the trick:
0) Upgrade the Date Field
Ensure that the Date Time field has been upgraded to to the newer Date field type.
Added a GIF to elaborate:
1) Asia/Kolkata
PARSE_DATETIME(
"%s",
CAST(CAST(FORMAT_DATETIME("%s",DateField)AS NUMBER) - DATETIME_DIFF(CURRENT_DATETIME("UTC"),CURRENT_DATETIME("Asia/Kolkata"), SECOND)AS TEXT))
Google Data Studio Report and a GIF to elaborate:

Asp.net Global Date Formats

I have an asp.net site which displays various data from a SQL backend to users which are in different time zones, i.e. PST, GMT, etc.
How can I easily display the dates on the page but in the time zone that the users are in and not the raw SQL date format?
I know it has to do with globalization settings but I have never used that before.
Use two resource (.resx) files with a 'Format_DateTime' key. Have a value 'dd-mm-yyy HH:mm tt' for the default and a 'mm-dd-yyyy hh:mm tt' for en-US.
In your page, call MyDate.ToString(Resources.Format_DateTime) .

Is there a way to get the user-preference Time Zone value from the Dwolla API?

The Dwolla transaction "Date" field apparently uses this value for generating a timestamp, but I don't see any way to get the "Time Zone" preference from the API?
Zooming out, I'm trying to get the definitive/comparable date for a transaction, but I need to know the timezone of the date string.
While this method doesn't state what the time zone is, others like this one make it clear that the dates are in UTC, so I would guess that all dates are in UTC throughout the API.
The only thing I don't like about their API is they are showing example dates like:
"Date": "8/31/2011 10:19:09 AM"
It's not very smart of them to use M/D/YYYY format, nor to use a 12-hour clock. This is better represented by "2011-08-31T10:19:09Z", which is in ISO format and indicates UTC. If you ever get a chance to speak with them, you should recommend they use this format (ISO-8601).
Just be aware of this when you are parsing it, since the format they are using may or may not be the correct format for your current culture.
Dwolla are making the change to the ISO timestamp on August 4th 2014
This change will be rolled out in 60 days from today, on 9:00 AM CT August 4th, 2014. If you need help making adjustments to your code to parse the new datetime format, let us know and we'll be glad to lend a hand.
https://discuss.dwolla.com/t/api-update-new-timestamp-format-for-clearingdate-parameter/401

How to handle date/times in POST parameters?

By default, Rails' config.time_zone is UTC. So, fields like created_at, updated_at are saved in UTC.
Now, presume user's time zone is Pacific Standard Time (PST).
In order to show dates and times in the user's time zone, I have set Time.zone to PST.
Now, when a user enters a date (in user's local time zone, which is PST) in a form, that date is received in the controller according to the setting of Time.zone.
But, I want to save all times in the database in UTC.
So, how would I go about converting any date/time field in-place in the parameters hash to UTC? I'm wondering if there is a solution where Rails can do the conversion automatically?
I would like that any date/time received for any datetime field be converted to UTC, without having to write the conversion code in every controller.
UPDATE
I tested by setting Time.zone to Pacific Time (US & Canada) as well as to Eastern Time (US & Canada) and then saving a model. The created_at time in both cases was in UTC. So that confirms that setting Time.zone has no effect on what time is saved by Rails in the created_at field. That value is effected only by the config.time_zone (which if not defined in application.rb will default to UTC)
I'm so confused by this all!
In the database, all dates are always saved as UTC. The config.time_zone parameter is setting the default value for Time.zone, just for display. So you don't have to do anything to get the behavior you desire, just keep Time.zone set correctly for the user, and rails takes care of the rest.