time

How to set default time zone in Java and control the way date are stored on DB?

大兔子大兔子 提交于 2020-01-13 05:00:07
问题 I've the following problem, that showed up when I installed my webapp's war on a virtual linux server. Here it is: my server system time seems correct, in fact typing date on shell comes out with: Mon Apr 11 11:47:30 CEST 2011 which is my "wall clock time". Even mysql works fine, if I do select now(), I get: mysql> select now() -> ; +---------------------+ | now() | +---------------------+ | 2011-04-11 11:52:57 | +---------------------+ 1 row in set (0.01 sec) But my application (Spring

Bash date/time arithmetic

自闭症网瘾萝莉.ら 提交于 2020-01-12 18:52:06
问题 I have a little Bash script which suspends the computer after a given number of minutes. However, I'd like to extend it to tell me what the time will be when it will be suspended, so I can get a rough idea of how long time I have left so to speak. #!/bin/sh let SECS=$1*60 echo "Sleeping for" $1 "minutes, which is" $SECS "seconds." sleep $SECS && pm-suspend The only argument to the script will be how many minutes from now the computer should be suspended. All I want to add to this script is

Bash date/time arithmetic

◇◆丶佛笑我妖孽 提交于 2020-01-12 18:50:33
问题 I have a little Bash script which suspends the computer after a given number of minutes. However, I'd like to extend it to tell me what the time will be when it will be suspended, so I can get a rough idea of how long time I have left so to speak. #!/bin/sh let SECS=$1*60 echo "Sleeping for" $1 "minutes, which is" $SECS "seconds." sleep $SECS && pm-suspend The only argument to the script will be how many minutes from now the computer should be suspended. All I want to add to this script is

Calculate Duration

末鹿安然 提交于 2020-01-12 17:29:06
问题 I have a small android problem, I have a requirement to have a timer to calculate the duration from the time a specific activity was open till a certain button in that activity is clicked, simply how long the activity was open. While googling around I found TimerTask but this seems to run a thread for a certain interval only though and doesent seem ideal for the job from my little Android experience Any idea on how to calculate the duration? Preferably in a very simple manner Any help is very

How can I convert time to decimal number in JavaScript?

家住魔仙堡 提交于 2020-01-12 16:12:47
问题 I'm too lazy to fill out my time sheet at work by the end at the end of every month, so I've started adding some functions to our PDF form. Acrobat Pro offers to make advanced calculations using JavaScript, but I'm stuck with this problem. I have two fields in which I enter the time when I start/end working. I want to calculate my overtime and output the result in a third field. however, I want the output to be decimal, so when I make half an hour overtime, the result would be 0.5 Example: my

How can I convert time to decimal number in JavaScript?

孤街浪徒 提交于 2020-01-12 16:08:26
问题 I'm too lazy to fill out my time sheet at work by the end at the end of every month, so I've started adding some functions to our PDF form. Acrobat Pro offers to make advanced calculations using JavaScript, but I'm stuck with this problem. I have two fields in which I enter the time when I start/end working. I want to calculate my overtime and output the result in a third field. however, I want the output to be decimal, so when I make half an hour overtime, the result would be 0.5 Example: my

C++: how to get the actual time with time and localtime?

淺唱寂寞╮ 提交于 2020-01-12 12:49:36
问题 I'm looking for a way to save the time in a HH::MM::SS fashion in C++. I saw here that they are many solutions and after a little research I opted for time and localtime . However, it seems like the localtime function is a little tricky, since it says: All calls to localtime and gmtime use the same static structure, so each call overwrites the results of the previous call. The problem that this causes is shown in the next snippet of code: #include <ctime> #include <iostream> using namespace

python - loop at exact time intervals

随声附和 提交于 2020-01-12 10:46:22
问题 I want to run a piece of code at exact time intervals (of the order of 15 seconds) Initially I used time.sleep(), but then the problem is the code takes a second or so to run, so it will get out of sync. I wrote this, which I feel is untidy because I don't like using while loops. Is there a better way? import datetime as dt import numpy as np iterations = 100 tstep = dt.timedelta(seconds=5) for i in np.arange(iterations): startTime = dt.datetime.now() myfunction(doesloadsofcoolthings) while

Creating a time range for AVAssetExportSession

安稳与你 提交于 2020-01-12 08:01:11
问题 I was wondering how to make a time range for AVAssetExportSession from time stamps such as: NSTimeInterval start = [[NSDate date] timeIntervalSince1970]; NSTimeInterval end = [[NSDate date] timeIntervalSince1970]; The code that I am using for my export session is as follows: AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality]; exportSession.outputURL = videoURL; exportSession.outputFileType =

Set time in php to 00:00:00

纵饮孤独 提交于 2020-01-12 07:24:49
问题 I need to display the time but it must start from 00:00:00? I've got the following but it uses the current time. print(date("H:i:s")); 回答1: As an alternative to mktime() , try the newer DateTime class, eg $dt = new DateTime; $dt->setTime(0, 0); echo $dt->format('H:i:s'); // Add one hour $dt->add(new DateInterval('PT1H')); echo $dt->format('H:i:s'); Update The flexibility of DateInterval makes this a very good candidate for a timer, eg // add 2 years, 1 day and 9 seconds $dt->add(new