I have a timezone string, for example, "Pacific Time (US &amp; Canada)". I need to get the equivalent of 3pm in that timezone in UTC for particular dates, including daylight savings time. How can I go about this?  For example, I need to find 3pm on December 3rd, PDT in UTC time.
492
I have a web page with three dropdowns for day, month and year. If I use the JavaScript Date constructor that takes numbers, then I get a Date object for my current timezone:  new Date(xiYear, xiMonth, xiDate)   Give the correct date, but it thinks that date is GMT+01:00 due to daylight savings time.  The problem here is that I then pass this Date to an Ajax method and when the date is deserialised on the server it has been converted to GMT and so lost an hour which moves the day back by one. Now I could just pass the day, month, and year individually into the Ajax method, but it seems that there ought to be a better way.  The accepted answer pointed me in the right direction, however just using setUTCHours() by itself changed:  Apr 5th 00:00 GMT+01:00    to  Apr 4th 23:00 GMT+01:00   I then also had to set the UTC date, month and year to end up with  Apr 5th 01:00 GMT+01:00   which is what I wanted.
93098
In SQL Server, how do I "floor" a DATETIME to the second/minute/hour/day/year?  Let's say that I have a date of 2008-09-17 12:56:53.430, then the output of flooring should be:   Year:  2008-01-01 00:00:00.000 Month: 2008-09-01 00:00:00.000 Day: 2008-09-17 00:00:00.000 Hour: 2008-09-17 12:00:00.000 Minute: 2008-09-17 12:56:00.000 Second: 2008-09-17 12:56:53.000
81732
How do you get the current time (not date AND time)?  Example: 5:42:12 PM
92316
I am working on a formula based on a date/time value to extract the time for the field. This field is based on the Pacific Time Zone and as is appears as  04/04/2016 9:00 PM  I set up this formula below  LEFT(RIGHT(text(  HOC__End_Date_Time__c ),9),7)  However the return result is based on GMT and returns based on a 24-hour clock, is there a way to adjust so it can simply display as 9:00 PM rather than as 24:00.  Hope it helps.
17597
We are developing a C# application for a web-service client. This will run on Windows XP PC's.  One of the fields returned by the web service is a DateTime field. The server returns a field in GMT format i.e. with a "Z" at the end.  However, we found that .NET seems to do some kind of implicit conversion and the time was always 12 hours out.  The following code sample resolves this to some extent in that the 12 hour difference has gone but it makes no allowance for NZ daylight saving.  CultureInfo ci = new CultureInfo("en-NZ"); string date = "Web service date".ToString("R", ci); DateTime convertedDate = DateTime.Parse(date);               As per :     UTC/GMT Offset       Standard time zone: UTC/GMT +12 hours   Daylight saving time: +1 hour   Current time zone offset: UTC/GMT +13 hours     How do we adjust for the extra hour? Can this be done programmatically or is this some kind of setting on the PC's?
35028
I want the server to always serve dates in UTC in the HTML, and have JavaScript on the client site convert it to the user's local timezone.  Bonus if I can output in the user's locale date format.
71224
I have this function...  private string dateConvert(string datDate) {         System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB");         System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US");          DateTime dtGb = Convert.ToDateTime(datDate, cultEnGb.DateTimeFormat);         datDate = dtGb.ToString(cultEnUs.DateTimeFormat.ShortDatePattern);          return datDate; }   But I want it with the leading zero still on lower digits (1-9) so the date is 11-09-2009 (mm-dd-yyyy)...  Now If I wasn't converting it id use string.Format("{0:d}", dateVar) how do I do this in the conversion?  ***** Solution ***** Used a slightly modified version of the answer below (i.e. one that would render).  Convert.ToDateTime(datDate).ToString("MM-dd-yyyy");
14455
I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected.  In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of where they are located.  From what I can see from the DateTime constructor I can set the TimeZone to be either the local timezone, the UTC timezone or not specified.  How do I create a DateTime with a specific timezone like PST?
59892
I have both Sales Cloud and Marketing Cloud connected and use data shared for a Journey when new records are created.  In my object that is triggered in the journey I have a Date/Time field which gets stored in SC in UTC, however in MC timezone settings are not stored in the field.  This means when using functions like SystemDateToLocalDate(@recordTimestamp) returns the wrong time as it thinks the original date is in CST (the system timezone instead of UTC).  Is this expected behavior?
51934
A few months ago I was introduced to the new  type and was glad 's flaws with regard to time zones were finally taken care of.  However, I was left wondering if there were any overhead or problems that could occur from using this new type.  I work on a multi-locale web application. Does anyone know of anything that could sway me from just using it for all my date/time work? Is there a window for abuse here?  Reference:
4347
Which PHP function can return the current date/time?
22646
This problem occurred during daylight saving time change. After the change occurred, we've noticed that our server application started writing into the log incorrect time - one hour ahead which means that .NET caches time zone offset. We had to restart our application to resolve this problem. I wrote a simple application to reproduce this problem. When I change the time zone while application is running, DateTime.Now property keeps producing the time in the old time zone. Does anybody know if there is a workaround for this problem apart from restarting the application?
48034
Does anyone know of a .NET date/time parser similar to  (handles stuff like "tomorrow" or "3pm next thursday")?  Note: I do write Ruby (which is how I know about Chronic) but this project must use .NET.
44986
I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?
73645
I wrote a little bash script that made me stumble across the . I did not know about this problem before and I just dare on posting the --debug output I got from date when my script tried to calculate across this magic date (03:14:07 UTC on 19 January 2038).  date -d "20380119"  date: parsed number part: today/this/now date: input timezone: +01:00 (set from system default) date: warning: using midnight as starting time: 00:00:00 date: starting date/time: '(Y-M-D) 2038-01-19 00:00:00 TZ=+01:00' date: '(Y-M-D) 2038-01-19 00:00:00 TZ=+01:00' = 2147468400 epoch-seconds date: output timezone: +01:00 (set from system default) date: final: 2147468400.000000000 (epoch-seconds) date: final: (Y-M-D) 2038-01-18 23:00:00 (UTC0) date: final: (Y-M-D) 2038-01-19 00:00:00 (output timezone TZ=+01:00) Tue Jan 19 00:00:00 CET 2038   date -d "20380119 + 1 days"  date: parsed hybrid part: +1 day(s) date: input timezone: +01:00 (set from system default) date: warning: using midnight as starting time: 00:00:00 date: starting date/time: '(Y-M-D) 2038-01-19 00:00:00 TZ=+01:00' date: warning: when adding relative days, it is recommended to specify 12:00pm date: error: adding relative date resulted in an invalid date: '(Y-M-D) 2038-01-20 00:00:00 TZ=+01:00' date: invalid date '20380119 + 1 days'   date -d "20380120" --debug  date: parsed number part: today/this/now date: input timezone: +01:00 (set from system default) date: warning: using midnight as starting time: 00:00:00 date: error: invalid date/time value: date:     user provided time: '(Y-M-D) 2038-01-20 00:00:00 TZ=+01:00' date:        normalized time: '(Y-M-D) 2038-01-20 00:00:00 TZ=+01:00' date:  date:      possible reasons: date:        numeric values overflow; date:        missing timezone date: invalid date '20380120'   Is there any way to make GNU date calculate across this date? (on a LINUX 32 bit system)    Operating System: Debian GNU/Linux buster/sid             Kernel: Linux 4.12.0-2-686-pae       Architecture: x86
120132
If the system time is changed on Linux, what files get edited? I know the timezone is kept in etc/timezone but is there anything if the timezone is not changed, but the time is?
83136
The best I can come up with for now is this monstrosity:  &gt;&gt;&gt; datetime.utcnow() \ ...   .replace(tzinfo=pytz.UTC) \ ...   .astimezone(pytz.timezone("Australia/Melbourne")) \ ...   .replace(hour=0,minute=0,second=0,microsecond=0) \ ...   .astimezone(pytz.UTC) \ ...   .replace(tzinfo=None) datetime.datetime(2008, 12, 16, 13, 0)   I.e., in English, get the current time (in UTC), convert it to some other timezone, set the time to midnight, then convert back to UTC.  I'm not just using now() or localtime() as that would use the server's timezone, not the user's timezone.  I can't help feeling I'm missing something, any ideas?