I have a linux machine in UTC timezone.  [user@test packages]$ date +'%:z %Z' +00:00 UTC   Running cat /etc/localtime also seems to indicate that my machine is in UTC timezone;  [user@test ~]$ cat /etc/localtime f2UTCTZif2UTC UTC0    However calling logger.info(new Date()) in a application running tomcat under Java 1.7 returns something like Mon Oct 28 01:51:39 HDT 2019  This is very strange, so I created a simple Java program for testing:  import java.util.Date;  class Test {         public static void main (String args[])         {                 Date dt = new Date();                 System.out.println(dt);         } }   Compile and run it  [user@test]$ /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.211.x86_64/bin/javac Test.java [user@test]$ /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.211.x86_64/bin/java Test Mon Oct 28 02:08:49 HDT 2019   My question is why my Linux utility is return date in UTC format, and yet my Java apps are returning dates in HDT format (I don't even know what HDT is).  Since the app I'm maintaining is legacy, I can't use Joda Time or upgrade to Java8 or higher as this would meant lots of code changes.
60964
I am running a Tomcat application, and I need to display some time values.  Unfortunately, the time is coming up an hour off.  I looked into it and discovered that my default TimeZone is being set to:  sun.util.calendar.ZoneInfo[id="GMT-08:00",                            offset=-28800000,                            dstSavings=0,                            useDaylight=false,                            transitions=0,                            lastRule=null]   Rather than the Pacific time zone.  This is further indicated when I try to print the default time zone's , and it comes up "GMT-08:00", which seems to indicate to me that it is not correctly set to the US Pacific time zone.  I am running on Ubuntu Hardy Heron, upgraded from Gutsy Gibbon.  Is there a configuration file I can update to tell the JRE to use Pacific with all the associated daylight savings time information?  The time on my machine shows correctly, so it doesn't seem to be an OS-wide misconfiguration.    Ok, here's an update. A coworker suggested I update JAVA_OPTS in my /etc/profile to include "-Duser.timezone=US/Pacific", which worked (I also saw CATALINA_OPTS, which I updated as well). Actually, I just exported the change into the variables rather than use the new /etc/profile (a reboot later will pick up the changes and I will be golden).  However, I still think there is a better solution... there should be a configuration for Java somewhere that says what timezone it is using, or how it is grabbing the timezone. If someone knows such a setting, that would be awesome, but for now this is a decent workaround.    I am using 1.5, and it is most definitely a DST problem.  As you can see, the time zone is set to not use daylight savings.  My belief is it is generically set to -8 offset rather than the specific Pacific timezone.  Since the generic -8 offset has no daylight savings info, it's of course not using it, but the question is, where do I tell Java to use Pacific time zone when it starts up?  I'm NOT looking for a programmatic solution, it should be a configuration solution.
49877
I'm trying to use the date command to generate a file timestamp that the date command itself can interpret.  However, the date command does not seem to like its own output, and I am not sure how to work around this.  Case in point:  sh-4.2$ date Fri Jan  3 14:22:19 PST 2014 sh-4.2$ date +%Y%m%dT%H%M 20140103T1422 sh-4.2$ date -d "20140103T1422" Thu Jan  2 23:22:00 PST 2014   date appears to be interpreting the string with an offset of 15 hours.  Are there any known workarounds for this?  Edit: this is not an issue of display:  sh-4.2$ date +%s 1388791096 sh-4.2$ date +%Y%m%dT%H%M 20140103T1518 sh-4.2$ date -d 20140103T1518 +%s 1388737080 sh-4.2$ python Python 3.3.3 (default, Nov 26 2013, 13:33:18)  [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; 1388737080 - 1388791096 -54016 &gt;&gt;&gt; 54016/3600 15.004444444444445 &gt;&gt;&gt;    It's still off by 15 hours when displayed as a unix timestamp.    EDIT #1  Maybe I should pose this question a little differently.  Say I have a list of ISO8601 basic timestamps of the form:   YYYYMMDDThhmm YYYYMMDDThhmmss   What is the simplest way to convert them to the corresponding Unix timestamps?   For example:  - 20140103T1422   = 1388787720 - 20140103T142233 = 1388787753
13403
I have a tiny script that simply fetches the current date, runs a PHP script and redirect the output (and errors) to a filename containing the current date.  DATE=$(date +"%Y%m%d") FILE="log/${DATE}.log" php -q script.php &gt;&gt; $FILE 2&gt;&amp;1   When I run this script on my local machine (Windows 7, Aptana IDE), the PHP script works fine and the logfile has the expected filename, e.g. 20140502.log.  But when I push that script via SFTP to my remote machine and execute that script, the filename looks like this:  20140502?.log?   What might be the problem? Is this an enconding error (e.g. encoding for SFTP uploads is ANSII, where UTF-8 is expected)? Or do I have to change anything in the script itself?  Information about system/shell:  [foo@bar path]$ sh --version GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)   Funny fact: If that script is called by a cronjob, the question marks don't occur. Only if I manually run the script.
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?
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?
23943
How can I execute a command making it believe that is on a different date than system one?  For instance, if I have this script:  #!/usr/bin/env bash     date +"%B %d, %Y"   It prints the actual date: march 13, 2014   But I would like it to print a different date, on the future or past, without changing the system date.  If I wasn't clear enough, I want a command line tool like .    I do not want to use a different script (it was just an example). I do not want to set a cronjob. I do not want to change my general system date. Only change the date that apply to the command to run.
87792
I asked  yesterday, approximately 18 hours ago ("2011-12-13 20:24:03Z" according to the hover text), and it's still being displayed as "today".  I assume the "Z" in the timestamp refers to Zulu time, so I , and the date (2011-12-14) differs from the timestamp on the question.  I don't pretend to understand all of the complexities when converting time zones, but I thought it was strange enough to report. If it matters at all, I'm in US-Eastern.
17519
I have a string containing the , and I need to convert it to a Java Date object.  String date = "1081157732"; DateFormat df = new SimpleDateFormat(""); // This line try {   Date expiry = df.parse(date);  } catch (ParseException ex) {   ex.getStackTrace(); }   The marked line is where I'm having trouble. I can't work out what the argument to SimpleDateFormat() should be, or even if I should be using SimpleDateFormat().
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?
83823
I need to display date and time in desired format in Unix/ Linux. My desired format is: dd/mm/yyyy hh:mm:ss:ms in Unix or Linux. I got close using the following command:  echo $(date +%x_%r)   This returns:  08/20/2012_02:26:14 PM   Any suggestions?
69654
I have changed my user Time Zone to "Pacific Daylight Time (America/Los_Angeles)". When i retrieve it through apex code(Timezone class) i'm getting result as       "Pacific Standard Time (America/Los_Angeles)". Does there any work around to fix this? And does it effect Timing differences?
51460
I've used the  function in Perl to get the current date and time but need to parse in existing dates. I have a GMT date in the following format: "20090103 12:00" I'd like to parse it into a date object I can work with and then convert the GMT time/date into my current time zone which is currently Eastern Standard Time. So I'd like to convert "20090103 12:00" to "20090103 7:00" any info on how to do this would be greatly appreciated.
3121
$ time foo real        0m0.003s user        0m0.000s sys         0m0.004s $   What do 'real', 'user' and 'sys' mean in the output of time?  Which one is meaningful when benchmarking my app?
36947
Apparently if I want to format a date to my own format ie. 1 June 2016 10:44 am I can only do this with outputText but output text does not respect the users time zone so everything is GMT. If I use outputField it automatically converts it to the users time zone but I have no control over the format it displays it in. Does someone know how to get my custom format to display in the users time zone? I don't care which I use I just want to show it my way in the proper time zone  This respects users time zone but I cannot control formatting  &lt;apex:outputField value="{!c.CreatedDate}"/&gt;   or This does not respect users time zone but I can control formatting   &lt;apex:outputText value="{0,date,dd MMM YYYY h:mm a}"&gt;   &lt;apex:param value="{c.CreatedDate}"/&gt; &lt;/apex:outputText&gt;   This method is called from the controller when page is called and populates the variable csComments with records  public void ShowComments() {   disp = true;   RetrieveAcctInfo();   caseNo = System.currentPagereference().getParameters().get('cn');   System.debug('Case No: ' + caseNo);   cd = [select id, AccountId, Priority from Case where CaseNumber=:caseNo];   if (acctid != cd.AccountId) { disp = false; errMsg = 'Access Restricted'; }    else {     csComments = [select Comment__c, CreatedDate from CSPComments__c where CaseCom__c=:cd.id ORDER BY CreatedDate DESC];     ccCount = csComments.size();   }   initpri = new List&lt;SelectOption&gt;();     initpri.add(new SelectOption('None',' -- Select Priority --', true));   initpri.add(new SelectOption('Level 1','1 - System Down'));   initpri.add(new SelectOption('Level 2','2 - Funtioning with Errors'));   initpri.add(new SelectOption('Level 3','3 - System Issue'));   initpri.add(new SelectOption('Level 4','4 - Non Critical Issue'));   inpri = cd.Priority;   curpri = inpri; }   This is the part of the page that is showing the results. The manager wants my date to be in the approved style of 1 June 2016 11:26 am    &lt;apex:pageBlock id="cl" rendered="{!disp}"&gt;    &lt;!-- Retrieved {!ccCount} comments&lt;br /&gt;  --&gt;     &lt;table&gt;&lt;tr&gt;&lt;th&gt;Date/Time&lt;/th&gt;&lt;th&gt;Comment&lt;/th&gt;&lt;/tr&gt;       &lt;apex:repeat value="{!csComments}" var="c"&gt;         &lt;tr style="padding:4px 0px 4px 0px"&gt;           &lt;td padding-right="4px"&gt;             &lt;!-- &lt;apex:outputText value="{0,date,d MMM YYYY h:mm a}"&gt;&lt;apex:param value="{!c.CreatedDate}"/&gt;&lt;/apex:outputText&gt;  --&gt;               &lt;apex:outputField value="{!c.CreatedDate}" /&gt;             &lt;/td&gt;           &lt;td&gt;&lt;textarea class="dtarea" rows="4" cols="60" disabled="true"&gt;{!c.Comment__c}&lt;/textarea&gt;&lt;/td&gt;         &lt;/tr&gt;     &lt;/apex:repeat&gt;     &lt;/table&gt;     &lt;/apex:pageBlock&gt;
25101
When I create a new Date object, it is initialized to the current time but in the local timezone. How can I get the current date and time in GMT?
18574
I'm trying to convert a date string into an age.  The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is.  I have sucessfully converted the date using:  &gt;&gt;&gt; time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200") (2008, 11, 17, 1, 45, 32, 0, 322, -1)   For some reason %z gives me an error for the +0200 but it doesn't matter that much.  I can get the current time using:  &gt;&gt;&gt; time.localtime() (2009, 2, 3, 19, 55, 32, 1, 34, 0)   but how can I subtract one from the other without going though each item in the list and doing it manually?
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.