Is it possible for me to get the UTC time of current hour in Javascript?   I've tried the following:  var mins = new Date().getMinutes(); var hours = new Date().getHours(); var hourStamp = new Date().setHours(hours, 0,0,0); var dates = new Date(hourStamp);   Here dates gives me the Unix Timestamp of the current hour. Is there a better/faster way to do this?   EDIT:   For example: I want the Timestamp for the current hour. So if it's 00:16 am on 12/04/2015, I want the timestamp of 12/04/2015 00:00. And, my method works. My question pertains to if there's a better method of doing the same.
40410
Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string.
70243
I'm trying to adjust this code so that I can jump to today's date which are all across row 2 in my spreadsheet.  function onOpen() {  var ss = SpreadsheetApp.getActiveSpreadsheet();  var sheet = ss.getActiveSheet();  var range = sheet.getRange("A:A");  var values = range.getValues();    var day = 24*3600*1000;    var today = parseInt((new Date().setHours(0,0,0,0))/day);    var ssdate;   for (var i=0; i&lt;values.length; i++) {    try {      ssdate = values[i][0].getTime()/day;    }    catch(e) {    }    if (ssdate &amp;&amp; Math.floor(ssdate) == today) {      sheet.setActiveRange(range.offset(i,0,1,1));      break;    }      } }    is from Marshmallow  I tried changing sheet.getRange("A:A") to sheet.getRange("2:2") and sheet.getRange("C2:PB2") but neither work.
33000
Does the .Net DateTime contain information about time zone where it was created?   I have a library parsing DateTime from a format that has "+zz" at the end, and while it parses correctly and adjusts a local time, I need to get what the specific time zone was from the DateTime object.   Is this possible at all? All I can see is DateTime.Kind, which specifies if time is local or UTC.
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.
52034
I'm curious as to what other administrators' experiences with timezones, in the context of remotely administered servers, are. In my career I've come across several conventions;   Always, always, always use UTC.   Always, always, always use the timezone of wherever base HQ is. Use the local time of the people who happen to be administering.  Use the local time of the server location.    In some places, I've come across multiple and conflicting conventions. My own preference has been to use UTC, always - with no daylight savings. But for one reason or another, it seems that most people prefer to use some concept of local time, with daylight savings. Although it seems like a straightforward technical matter, discussions around changing conventions always seem to trend towards religious schisms.  What are you using? What do you consider to be the advantages and disadvantages of each approach?
122501
The following code returns the time of the current date:  System.debug('Current date: ' + Date.today().toStartOfMonth());   Output:     2018-08-01 00:00:00   How to remove time from date?
105204
Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT?  Bonus question: If given the date/time as a string, how would you first parse it into the (y,m,d,h,m,s) array?
52755
I need to get the current time but to be in type DateTime. I use:  DateTime now = System.now();   but it returns wrong time. I execute the code in 2017-08-04 00:38:46 AM but it returns     00:38:46:023 USER_DEBUG [138]|DEBUG|now 2017-08-03 21:38:46   How can I get my correct current local time 2017-08-04 00:38:46?  I had even tried with:  DateTime now = DateTime.parse(System.Now().format());   but I still get wrong time.     01:10:09:021 USER_DEBUG [139]|DEBUG|now 2017-08-03 22:10:00   How can I get the correct current local time?
111856
How do you format the date time to just date?   For example, this is what I retrieved from the database: 12/31/2008 12:00:00 AM, but I just want to show the date and no time.
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?
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?
388
What does Salesforce use as the system time when running those jobs? The current system time (UTC)?  My context is that I have a job that is run every 30 minutes and it executes a task for some of my users. The User object has 4 numeric fields to represent start hour, end hour, start minute and end minute. With those fields I calculate the second in the day the job should start, and the second it should end. With those two values I can compare with the system's current second, and check if the job should run for the user or not.  Some days ago this was a scheduled class that was rescheduling itself using my user credentials ('Scheduled by Renato' and records would be marked as 'Last modified by Renato' too). Then I decided to change to platform events so they would be marked as "Last modified by Automated Process" instead (which is what I want).  Now everytime the class is run, it publishes a event, and the event trigger fires the class' code that was inside the execute block. However, the timing seems off, and users are not receiving the tasks in the correct time anymore.  To get the current second correctly, I've used this code:  Integer offset = TimeZone.getTimeZone('America/Sao_Paulo').getOffSet(DateTime.now()); Integer current_second = Util.getCurrentSecond() + (offset/1000);   Util class' method:  public static Integer getCurrentSecond() {     return Integer.valueOf((DateTime.now().hour() * 60 * 60) + (DateTime.now().minute() * 60)); }   Have I not considered something when using the Platform Events?  Edit:  I just edited my code to include a call to a service that sends a message to me through Telegram. The code ran in the platform event context, and the timing is correct. System time is UTC and São Paulo is UTC-2 (originally -3, but -2 because of Daylight Saving Time):  System second: 21960 Current second: 14760
13404
The  explains how to put a Datetime query in a SOQL query.    SELECT Id FROM Account WHERE CreatedDate &gt; 2005-10-08T01:02:03Z   I need to just put in a date for this query. Something like:   SELECT Id FROM Account WHERE CreatedDate &gt; 2005-10-08   But that throws an error. Any ideas?
24173
What is the best way to convert seconds into (Hour:Minutes:Seconds:Milliseconds) time?  Let's say I have 80 seconds, are there any specialized classes/techniques in .NET that would allow me to convert those 80 seconds into (00h:00m:00s:00ms) format like to DateTime or something?
64277
Just curious as to what the reasoning behind making the time stamps for the questions and answers in UTC instead of localizing the time for the client.  I do realize it's easier to store the value in UTC.  But, I would guess most of us think in local time and showing the date and time of the post isn't as meaningful if it's in UTC, having to do a conversion each time we see it.  I think it would be more useful and intuitive if it showed "answered Jul 2 at 15:38 EST" where EST is the viewer's local time zone.  It's possible I'm just not Skeet enough to think in Coordinated Universal Time.  (Skeet is an adjective as well as a verb, right?)    EDIT: As noted by me and others, perhaps defaulting to UTC, but allowing a user to select a different timezone in their profile would be a reasonable request.
67697
I have tried using =TEXT(Today,"mm-dd-yyyy hh:mm:ss") but that only returns the 5/5/55 00:00:00, it won't give the time. How do I get both the date and time with a calculated formula?
1793
Is there a standard way for a web server to be able to determine a user's timezone within a web page?   Perhaps from an HTTP header or part of the user-agent string?