FAQ Database Discussion Community


Ruby Initialize a Variable to Current Time

ruby-on-rails,ruby,time,updates
I have a Rails 3 Application that needs to use the current time. Every time an admin uses a function populateTable, the lastPopulation variable needs to update to the current time. Two questions: 1) How can I initially set the lastPopulation variable to the current time right now? 2) Is...

How to use TIME type in MySQL?

mysql,time
I'm building my first DB through MySQL Workbench. In a table I need to store a time attribute that contains minutes and seconds. In this regard, I wanted to use the TIME data type. What is the argument required by the type TIME(...)? Thanks...

Notification Message Instantly Fired - Android

android,time,notifications,broadcastreceiver,alarmmanager
I'm making an app that stores medicines data in an SQLite database in order to send to the user notifications when it's time to take them. I already created the BroadcastReceiver class and managed the notification Intent. The Calendar.set() function is called when I add the time (hh:mm:ss) in the...

How to Minus time with python

python,time
I'd like to get the time before X seconds before datetime.time.now(). For example if the time.now() is 12:59:00 so If I minus 59, I want to get 12:00:00. I can't find a way to do that. Any help will be appreciated....

Disk read/write perfomance in linux

linux,time,dd
I wanted to check the read/write performance of my disk. I am executing the below command to write into a file time dd if=/dev/zero of=/home/test.txt bs=2k count=32k; which gives about 400MB/s For checking the read performance i have executed below commands.with and without 'of' parameter. There is a huge difference...

Javascript update time function causes high CPU

javascript,performance,date,time
I have the following code that I am using to display the current date and time, and I want it always updated so I have a setInterval to update it every second. This seems to be causing the page to be taking up 25% of the CPU and the memory...

Why is Array.splice() so slow?

javascript,arrays,performance,time
I recently saw this benchmark: http://jsperf.com/remove-element-splice-vs-move-and-pop I noticed that Array.splice() is several orders of magnitude slower than a for loop iterating through the elements. This lead me to wonder why Array.splice() is so slow. Therefore, I came here to ask you: Why is Array.splice() so slow?...

how extract real time form time.gov in python?

python,time,ntp
I want to show real time in my program from time.gov. I saw ntplib module and this example: import ntplib from time import ctime c = ntplib.NTPClient() response = c.request('europe.pool.ntp.org', version=3) ctime(response.tx_time) but I can't use time.gov instead of 'europe.pool.ntp.org' because time.gov is not a ntp server. Also I saw...

Parsing a timestamp with time zone [duplicate]

java,parsing,date,time,timestamp
This question already has an answer here: java.text.Parse Exception : Unparseable Date 2 answers I want to parse a timestamp given in this format timestamp="2015-05-21 12:38:00Z" using the class SimpleDateFormat. The problem is the "Z" in the end of timestamp which specifies the time zone. Unfortunately new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ")...

Subset a dataframe based on time variable

r,date,datetime,time,subset
I have the following dataframe which is already a subset of a much larger dataframe: Time X.N2O._ppm 1 15/05/2015 13:30:07.291 0.03941801 2 15/05/2015 13:30:08.307 0.01014003 3 15/05/2015 13:30:09.323 0.02577801 4 15/05/2015 13:30:10.338 0.02554231 5 15/05/2015 13:30:11.354 0.02489800 6 15/05/2015 13:30:12.370 0.02417584 7 15/05/2015 13:30:13.386 0.02489115 8 15/05/2015 13:30:14.402 0.02524912 9...

How can I set minDate in DatePickerDialog to be after 2 days

android,date,time,picker
I created a DatePickerDialog in my Activity, and I am trying to set the minDate to after 2 days. For example, today is 25/5/2015, and I want the minDate to be: 27/5/2015 This is the code: final DatePickerDialog dpd = new DatePickerDialog(TestActivity.this,listener,calendar.get(Calendar.YEAR) ,calendar.get(Calendar.MONTH) ,calendar.get(Calendar.DAY_OF_MONTH)); DatePicker dp = dpd.getDatePicker(); dp.setMinDate(//I want...

Time stamp missing

c#,time,serial-port
I'm trying to display the data received on textbox. But I realized that when data were being received on [email protected] terminal it look fine (eg. 14:02:33.43 > T 11 22.32) but running on the software the time stamp is missing. Am I missing out anything which lead to this? using...

Small Basic - How to check if a date is passed?

time,smallbasic
I'm trying to make a license verification that should expire in a week with small basic. I could make a script that would write down the day the license was activated and that would expire the license as soon as the current day is 7 larger than the written amount....

Convert long int seconds to double precision floating-point value

c++,date,datetime,time,converter
I have a long int variable wich containes seconds since Jan. 1, 1970 in this format: long int seconds = 1231241242144214; i need to convert this seconds to double precision floating-point value. The integer part of the value is the number of days since midnight, 30 December 1899. The fractional...

Why does it take so long to start a for loop?

java,loops,for-loop,time
Given the following (which I have taken from a larger program) t1 = System.currentTimeMillis(); for (int i = 0; i < 3; i++) { t2 = System.currentTimeMillis(); for (int j = i; j <= 1000; j += 3) { t3 = System.currentTimeMillis(); //j loop body } } When I run...

Why this while loop cannot print 1,000 times per seconds?

java,loops,time,while-loop
The following Java method is meant to print the number i by nLoopsPerSecond times per second for seconds seconds: public void test(int nLoopsPerSecond, int seconds) { double secondsPerLoop = 1.0/(double)nLoopsPerSecond; long startTime = System.currentTimeMillis(); long currentTime; int i = 0; while ((currentTime = System.currentTimeMillis()) < startTime + seconds*1000) { System.out.println(i++);...

Python - creating a delay that takes in account the execution time

python,image-processing,time,delay
i am writing a function that reads N (800*600) frames from a bin file in one sec. the FPS is user controllable import time def getFrame(file,N): #read N frames per second, 800X600 pixels each from file start = time.time() delay = (1/float(N)) while N: frame = file.read(480000) time.sleep(delay) N -=...

Performance measures : Java vs JavaCard [closed]

java,performance,time,smartcard,javacard
I implemented two algorithms in Java. To compare their effectiveness, I call each function 1000 times and compare the execution time (using System.currentTimeMillis()). It needs 2500 ms to execute the first one and 1300 ms for the second one. With these results, I thought have a significative difference (in term...

Perform a task each interval

java,time,schedule
So I'm trying to schedule a time instance where it repeats every 10 seconds. Right now I have something that does a task after 10 seconds, but how do I make it so that it resets after doing so. this.schedule = TimerManager.getInstance().schedule(new Runnable() { @Override public void run() { chrs.get(0).getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(100100),...

Use XSLT to convert date time to full words

xml,date,xslt,time,formatting
I am just starting to learn XSLT and am hoping to convert some XML time and date data so that it is fully spelled out. While I have seen methods to have the date information output as words (12 to December) I don't see anything that allows be to convert...

How can i make python take a data time in format hh:mm:ss and store it in an array? [closed]

python,time,format
I have a list of csv file which contains several columns. There's one that contains the lenght of my test in this format hh:mm:ss I need to divide this data in two database based on lenght: <00:16:00 or >00:16:00 How can I do that? Thanks for helping and sorry for...

Android-Reduce the time when retrieving data

android,time,httprequest
I'm using httpRequest in Android to retrieve and store data from an online shopping website(such as lazada.com.my). Anyhow, I've notice that this method would require several minutes in order to complete the whole httpRequest. I was wondering are there any other method to reduce the time required to retrieve data...

jQuery: Clear input field if it is not filled in certain time? [closed]

javascript,jquery,input,time
Using jquery or js, how can I clear an input field if it doesn't reach x amount of characters in a certain time? Basically, if an input field doesn't reach 10 characters in 1 second, I want to clear any input that was typed. How can I calculate the time...

ORACLE SQL: Select records with time difference less than a minute

sql,oracle,time,difference
I have a table in which I have same the records but with different timestamps. E.g. - 1 2015-03-03 13:41:11.0 [createService]: [accountNumber = 123456] 2015-03-02 01:19:11.0 [createService]: [accountNumber = 123456] 2015-03-02 01:19:06.0 [createService]: [accountNumber = 123456] E.g. - 2 2015-03-07 01:21:11.0 [createService]: [accountNumber = 567890] 2015-03-04 01:17:11.0 [createService]: [accountNumber =...

Timing in C with time.h

c,time,time.h
I am working on Ubuntu, and I want to time an assembler function in C. Thats my code: #include <time.h> #include <stdio.h> #include <unistd.h> extern void assembler_function(char*,int); int main(){ char *text1 = "input.txt"; clock_t start=clock(); sleep(3); // used for test //assembler_function(text1,0); clock_t stop=clock(); //printf("%d %f\n",(int)stop,((float)stop)/CLOCKS_PER_SEC); printf("Time : %f \n",(double)start/CLOCKS_PER_SEC); printf("Time...

DateTimeFormatter - parsing string with time zone

java,time
I have a JSpinner for selecting specific time (with today's date) and I need to convrert the String result into LocalDateTime instance. However, I can't seem to write the regex string right. Could you tell me what am I doing wrong, please? JSpinner: SpinnerDateModel sm = new SpinnerDateModel(date, null, null,...

display message if time difference is greater than 50 minutes - php

php,datetime,time
Basically i'm getting time difference between current time and database time. $cur_time = time(); $db_time = $rs[$k]['update_time']; $diff = abs($cur_time - $db_time); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); $hours = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24...

How to stub Time.now.hour

ruby-on-rails,testing,time,rspec,stubbing
I have a helper method which outputs a greeting #{greet(Time.now.hour)} in the view pending the time of day: users_helper.rb: def greet(hour_of_clock) if hour_of_clock >= 1 && hour_of_clock <= 11 "Morning" elsif hour_of_clock >= 12 && hour_of_clock <= 16 "Afternoon" else "Evening" end end And I am trying to test this...

Android: Time Loop in milliseconds

android,android-activity,time
This game is similar to one of those where your try to survive for as long as possible, like those hell-shooter games. So basically I wish to record to amount of time the user can survive after pressing "start". Similarly, I would like to continue to update the frames at...

How to check a time array if the single values are in +/- 15 minute range of another time

php,time,logic,strtotime
What should I do to make a 4 digit integer/string to behave (not look) like time? Consider this code: $t = 0430; $timeArray = array('0400', '0415', '0420', '0430', '0440', '0450', '0500', '0600'); Now if I have to search $timeArray for elements which are +/- 15 min from $t I would...

Swift - generate random Integer between 0.1 and 0.6

ios,swift,time,int,delay
I'm having trouble with Swift trying to generate a random number between 0.1 and 0.6 I want to introduce a micro delay into a simple game to make it look like the iPhone is having to "think" before responding. I have found various snippets to generate a random number (none...

I want to know how to display curent time in PHP [closed]

php,time
I want to know how to display time since a user has submitted the form on my website. So for example when the user submits the form I was to display "Thank-you for your submission. You have been logged in for 0 seconds" depending upon the time that has elapsed."...

Set LocalDateTime to autogenerate with hibernate 4.3.10

java,hibernate,time
Currently I have a base entity as follows: @MappedSuperclass public abstract class BaseEntity { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) private Long id; private boolean deleted; @Convert(converter = LocalDateTimePersistenceConverter.class) private LocalDateTime createdAt; @Convert(converter = LocalDateTimePersistenceConverter.class) private LocalDateTime updatedAt; } Is it possible to annotate LocalDateTime with something to make database default to current date...

Is timezone info redundant provided that UTC timestamp is available?

datetime,time,timezone,timestamp,timestamp-with-timezone
I have a simple mobile app that schedules future events between people at a specified location. These events may be physical or virtual, so the time specified for the event may or may not be in the same timezone as the 'location' of the event. For example, a physical meeting...

Reduce writing time of data

python,optimization,time,writing
I'm post-processing CFD data (applying a rotation to the coordinates). To do that, I'm doing the following: -Read a file -Store the data into structured array -Manipulate the data (do the calculations) -Write a new file It works but it takes 7seconds per file. And I have (15000 * 4)...

time formatting in matlab

matlab,time,format
I have time series per minute that look as shown below. The format is like '"hh:mm"' as seen below '"8:59"' '"9:00"' '"9:01"' '"9:02"' '"9:03"' '"9:04"' '"9:05"' '"9:06"' '"9:07"' Is it possible to change these to hhmm format in matlab like 859 900 901 902 t0 a double format. ...

Format Date VARIABLE to short date VBA

vba,date,time
I have a user inputted via a userform.textbox.value. General date that I want to switch to a short date. (Or try to get the time to drop so it reads 00:00). I tried the code sDate=format(date,(d)) but that returns the current date rather than the variable date without the time....

PLSQL Need REFCURSOR DATE + TIME

date,time,plsql,cursor
im using this code and I had 1 problem, the o_besteltijden cursor has this as output: 01-06-15 ( a date), but I prefer output like: 16:00 (so only time) Or 01-06-15 16:00:00 (date + time). is that possible? SET SERVEROUTPUT ON; CREATE OR REPLACE TYPE t_openingstijd IS TABLE OF DATE;...

How To Compare six time on PHP?

php,time
I have problem with compare 3 Time on PHP. So the user just input a time now(). but it must have compare with 3 Different time which have been load from database. the code like this if(isset($_POST[SUBMIT])) { $waktu = strtotime($_POST[WAKTU]); //$waktu variabel input set hh:mm /*Get Time Setting From...

Compare multiple server times to localtime

bash,shell,date,time,scripting
I am looking to compare x amount of server times to a control local time(current time at the running of the script) to check if any of the servers are out of sync with the current time. If the servers are more than a few seconds behind then throw and...

Timer in Python(simultany)

python,time
I have been looking for a timer to my project, but I only found timers that stop my code. Does Python got an option to run a timer in a way that doesn't stop my other code? Tl;Dr simple working timer that works simultany Thanks in ADVANCE!...

Convert double to time_t

c++,time,standards,chrono,time-t
I have a double containing seconds. I would like to convert this into a time_t. I can't find a standard function which accomplishes this. Do I have to fill out the time_t by hand?...

Android: automatic logout

java,android,time,login,logout
Hi I want to logout automatically after a determined time of inactivity my Android app. In the Second Activity in onPause I save the time when the app is in pause in a variable. In MainActivity in method onresume I save the time when the app restarts in another variable...

String to Time in Javascript

javascript,time
I have an input form for date, which gives me a string such as 06/01/2015 Using it I need to get two variables in time format for the beginning of the day and the end of the day (00:00:00, and 23:59:59) in time (milliseconds) format such as 1433206800000, 1433205690000. Can...

RegEx matching HH:MM, HH:MM:SS OR HH:MM:SS.XXX

regex,time
So far I have the following: ^(([0-1][0-9])|([2][0-3])):([0-5][0-9])(:([0-5][0-9]))?([.]\d{1,3})?$ This matches (as expected) 23:59, 23:59:30, 23:59:34.123 or 23:59:12.1 Doesn't match 23:60, 23:59. But unfortunately matches 23:59.60 Any ideas how to give the finishing touches?...

Operators suddenly not working

time,vbscript,operators
A week ago I wrote this script which starts up when you log in and then greets you according to the time of the day. This morning it suddenly suddenly said: "Invalid time" (it would do that if all other elseif options wouldn't match the time). This used to work...

Batch - xcopy files older than x minutes

batch-file,time,copy
after a new file creation time of 20 min I want to copy all files with the extensions .txt from Folder New to Folder Target. (I want to copy olny files are older than 20 min) So far, it looks like this: set hh=%TIME:~0,2% set mm=%TIME:~3,2% set ss=%TIME:~6,2% set /a...

How to prevent MatLab from freezing?

matlab,memory,time,evaluation
Is there a way to limit the amount of time an evaluation is allowed to run? Or limit the amount of memory that MatLab is allowed to take up so it doesn't freeze my laptop?

Function to calculate values comparing sequential time periods

r,function,time,plyr
I have been unable to find a solution to my query on Stack Overflow. This post is similar, but my dataset is slightly - and importantly - different (in that I have multiple measures of 'time' within my grouping variable). I have observations of organisms at various sites, over time....

Why Google Analytics show bounce rate 100% and avg time more then 1min

time,google-analytics,bounce,rate
How is possible to have on a page a bounce rate = 100% and for the same page an average time on page > 1min ? screenshot here...

Teradata Convert DATE to midnight

date,time,teradata
below is the original code convert(datetime, (substring(convert(varchar(26), convert(datetime,getdate())),1,12) + '23:59:59:996')) output is = 6/17/2015 11:59:59.996 I converted it to Teradata below CAST(CURRENT_TIMESTAMP AS DATE FORMAT 'MM/DD/YYYY') || ' 23:59:59:999990' but upon compiling my store proc, it produces an error below Invalid or missing expression 'E(5404):Datetime field overflow.'. Is there a...

How can I extract only hours and minutes in the format HH:MM from a HH:MM:SS time string?

php,string,date,time
I'm getting the time in this format: 0:18:32 If I do var_dump() I get: string '0:18:32:���' (length=11) The time is saved in my DB as 18:32:00. I want to get HH:MM out of this and I've tried the following code, but it doesn't work as expected. $AdmissionTime = strftime("%H:%M" ,$patient['TIME_UNIT_ADM']...

Convert Epoch timestamp to date format

datetime,time,epoch
I have a .json file with lots of documents, each document is like this: {"_id":{"$oid":"54ff56116d"},"caption":{"created_time":"1421434541",....} I need to convert created_time to date format in each of my documents. Do you have any idea?...

Show a timer in a Java Frame

java,time
I want to show the elapsed time of a game i'm doing. Basically i want to call the class that keeps track of the score and with calling the class i want to start a timer that just continually runs and shows the elapsed time, this should be added. Is...

Bash variable expansion can't be combined with time command

linux,bash,shell,time
I was writing a small shell script in bash to measure the speed of several executables using the time command. Because I wanted to time several different programs, to avoid repeating myself I saved the time command and the format string I wanted and tried to use variable expansion (testing...

Echo of time not displayed at end of batch file

batch-file,time,echo
Here is my batch file: @echo off set start=%time% echo %start% for /d %%i in (*) do ( mkdir "%1\%%i" cd %%i for %%j in (*.mp4) do ( echo "%1\%%i\%%j "..\ffmpeg32" -loglevel panic -i "%%j" -c:v libx264 -preset fast-crf 50 -c:a copy -y "%1\%%i\%%j" ) cd .. ) set end=%time%...

How to convert date into timeago

javascript,html5,time,timeago
I am trying to convert a date field in a "timeago" format using jquery.timeago.js $("time.timeago").timeago(); var userSpan = document.createElement("span"); userSpan.setAttribute("class", "text-muted"); userSpan.appendChild(document.createTextNode(message.usernameSender +" | ")); var timeTag = document.createElement("time"); timeTag.setAttribute("class", "timeago"); timeTag.setAttribute("datetime",document.createTextNode(message.date)); userSpan.appendChild(timeTag); This javascript will genearate the following code <span...

php why do i allways get a 1 on date [duplicate]

php,date,time
This question already has an answer here: A non well formed numeric value encountered 5 answers so this is weird i dont understand why i am getting this but anyway my code is $checkTime = "00:00"; echo 'Check Time : '.date('H:i', $checkTime); echo "<br>"; the value allways gets output...

PHP - Count how many days ago

php,mysql,date,time,count
In my database I have a bunch of Last Login dates for my users. They are written like this: Last Login: Apr 08 2015, 22:53:49 CEST And: Last Login: Apr 08 2015, 22:53:49 CET So both CEST and CET at the end can occur. What I'd like to do is...

having issues with python time object

python,date,time
i am having a small program that gets time from system and dose some arithemetic on it. here is my code: import time import datetime c_time = time.strftime("%H:%M;%S") # now to convert it into time object i am using c_time_converted = datetime.datetime.strptime(c_time,"%H:%M;%S") print c_time_converted the output is of the form...

R help converting char to POSIXlt

r,datetime,time,strptime,posixlt
I am having a lot of problems converting a char data.frame into a POSIXlt. This is my str output: 'data.frame': 5846 obs. of 5 variables: $ date : Factor w/ 184 levels "1/1/2015","1/10/2015",..: 31 31 31 31 31 31 31 31 31 31 ... $ time : Factor w/ 680...

How to check if two times overlap in PHP?

php,time,compare,unix-timestamp
So I'm trying to figure out how to check if two times overlap using PHP and a MySQL database. This is the function I'm using to check if they are overlapping: function testRange($start_time1,$end_time1,$start_time2,$end_time2) { return ($end_time1 < $start_time2) ? false : ($start_time1 > $start_time2) && ($start_time1 > $end_time2) ? false...

Android - Re-use TextView showing current date time in multiple activities

android,time,textview
I have some activities displaying the current date and time. I want to make only one text view (layout) txtTime showing time and it will be updated each second by a handler in main activity. Then others views of other activities can re-use the text view txtTime by including. (I...

What is the real code behind digital clocks? Java [closed]

java,time,clock
I know it's kind of naive question, and maybe out of place, but I was really wondering the secret behind the functionality that is used to calculate the right timing for seconds, minutes, and hours in computers? Since, as you know, computer doesn't create things by itself, and numbers doesn't...

Convert string 06/12/2015 12:00 PM to date format JavaScript

javascript,time
How to convert string 06/12/2015 12:00 PM to date format (milliseconds) in JavaScript. new Date('06/12/2015 12:00 PM') gives me invalid date. Thank you for your time....

Response Time Accuracy

python,time,python-3.4,psychopy
I am going to program a response time experiment in Python 3.4 with Pygame and PIL. Will Python's builtin time functions be accurate enough for a millisecond level accuracy of response times? Is PyParallel necessary, or is it necessary only for EEG or eye-tracking experiments?

Regex pattern for date and hour

regex,date,time
I want to use regex to validate text fields in JSF. Could someone tell me the pattern for hours (hh: mm) and date (dd / mm / yyyy). I tried the following patterns, but without knowing anything. <f:validateRegex pattern="[0-9][0-9]:[0-9][0-9]" /> <f:validateRegex pattern="[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]" /> ...

12 Hour Clock Array Sort

php,arrays,sorting,time,clock
I have been searching on Google and couldn't find any solution to sort an array according to the 12 Hour clock format. I was able to sort the 24 hour clock by converting it to timestamps and then using krsort. But I am not sure how to sort a 12...

Find number of days in Perl

perl,time
I have two dates in the format year-month-day hour:minute:sec For example : 2015-01-01 10:00:00 and 2015-01-10 11:00:00. I want to calculate number of days between these two days as 10. I tried localtime function, but didn't work. I need a solution for this in perl. Please help....

Select By Time And Date [closed]

mysql,sql,date,time
I have a table with Date Time Column id name date_time 1 test 2015-12-10 22:00 1 test2 2015-12-20 20:00 1 test3 2015-12-13 05:00 1 test4 2015-12-15 11:00 I need write a select where date_time > 28 h from my date For Example we put 2015-12-15 12:00 , the result shown...

convert time to to 12 hour by manipulate string

javascript,jquery,datetime,time
"2015-06-23 14:00:00" I tried to format above date time into 12 hour base but stuck in somewhere. function formatDate(raw_date){ var right = raw_date.substring(10, 0); var hours = ((right[0].substring(2,0) + 11) % 12 + 1); var min = raw_date.substring(14,16); var suffix = right[1] >= 12 ? "PM":"AM"; right[1] = ((right[1] +...

Changing div style for every day of the week script

javascript,css,time
This is my project: http://jsfiddle.net/yL0o1cy0/ .calendar { width: 850px; height: 500px; background-color: #141414; border-radius: 10px; padding-top: 10px; margin-top: 15px; margin-left: 15px; } #calendartest1 { width: 778px; height: 200px; position: relative; margin-left: auto; margin-right: auto; } #calendartest2 { width: 778px; height: 200px; position: relative; margin-left: auto; margin-right: auto; margin-top: 50px; }...

How do you start a function at a certain time in Python?

python,multithreading,events,time,condition
I have a list of timestamps, and I need to call a specific method when those timestamps are reached. Those timestamps are roughly 20ms apart. At the moment I am using busy waiting in a separate thread, but I am worried about the CPU overload. Example : while True: if...

Javascript time differs from Java time

java,javascript,servlets,time
i'm running a JavaServlet and as JavascriptApp on the same machine. The servlet outputs the current time: @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ServletOutputStream os = resp.getOutputStream(); os.print("" + System.currentTimeMillis()); } The JS Gets the time: $.get("UserdataServlet", function(data) { console.log("dy " + data); console.log("my "...

Converting date format in PHP (but what format is this in?) [duplicate]

php,date,datetime,time
This question already has an answer here: Convert one date format into another in PHP 9 answers I'm using the Envato API to verify purchases made on their site, and the date/time outputted as part of an API query for the purchase is like so: Wed May 20 06:37:57...

PHP Timezone not working correctly

php,date,time,timezone
So we have in-house servers here in this EDT part of the USA America/New_York and for someone reason, this [SSCCE][1] code is not working. <?php echo date_default_timezone_get() . " <br />"; $dateCal = "2015-06-22 13:00:00"; // EDT Time $schedule_date = new DateTime($dateCal, new DateTimeZone("America/Chicago") ); echo $dateCal . " <br...

Repeat a sound/action every certain time

python,date,time,while-loop,repeat
I'm trying to write a Python program that reproduces a sound every certain hour, but it doesn't really work. When I test the code and the specified time comes, it will keep repeating the sound forever. Here is the code: import os from datetime import datetime now = datetime.now() currentHour...

Check day of week and time

php,time
I have been trying to figure out how to get between a day of week and time...I found this snippet of code: function isBetween($from, $till, $input) { $f = DateTime::createFromFormat('!H:i', $from); $t = DateTime::createFromFormat('!H:i', $till); $i = DateTime::createFromFormat('!H:i', $input); if ($f > $t) $t->modify('+1 day'); return ($f <= $i &&...

Why are my nested for loops taking so long to compute?

algorithm,matlab,time,big-o,nested-loops
I have a code that generates all of the possible combinations of 4 integers between 0 and 36. This will be 37^4 numbers = 1874161. My code is written in MATLAB: i=0; for a = 0:36 for b= 0:36 for c = 0:36 for d = 0:36 i=i+1; combination(i,:) =...

Time format conversion with PHP

php,time
If have the duration for a recipe in the format 1H10M (1 hour, 10 minutes) or 20M (20 minutes). I want to use the format as described in the parentheses. I've tried using strtotime() without luck. Any help would be greatly appreciated....

need the way to put Date in Parse.com without Time and the opposite

android,date,time,parse.com
Can't figured how to put just Date or just Time to Parse.com. Even after SimpleDateFormat the Date objects transferring with full default missing data. Code samples: DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); DateFormat timeFormat = new SimpleDateFormat("HH:mm"); try { date = dateFormat.parse(mDate.getText().toString()); time = timeFormat.parse(mTime.getText().toString()); } catch (java.text.ParseException e) { ......

Multiplication of a time in PHP

php,time
I need multiplication of time in PHP $maritime ='01:10:00'; I need increment this $maritime in to 5 I want to get answer like this 01:10:00*5 = 05:50:00 ...

What is this Time Format 1381039499

time
could someone explain me what is this Time Format? 1381039499 I do not know how should I have to change it to normal Time format...

Using Master theorem to calculate asymptotic time complexity of algorithm

algorithm,time,complexity-theory,master,theorem
Problem: You have an algorithm that divides n size problem to six subproblems with size of one quarter of the original. For dividing the algorithm makes 100 steps and for merging 75n. What's the time asymptotic complexity of an algorithm? So the formula for Master Theorem and for this problem...

Ruby - Convert formatted date to timestamp

ruby,date,time,timestamp
I need to convert a date string to the Unix timestamp format. The string I get from an API looks like: 2015-05-27T07:39:59Z with .tr() i get: 2015-05-27 07:39:59 which is a pretty regular date format. Nonetheless, Ruby isn't able to convert it to Unix TS format. I tried .to_time.to_i but...

Mysql - records from last 30 days, but 1 and 2 months ago

mysql,date,time
This query is selecting rows applied last 30 days: SELECT `amount` FROM `mg_inputs` WHERE `amount`<0 AND `product`='144' AND DATE(firstedit) BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE() How about queries selecting rows applied last 30 days, but 1 month ago (between: today-30days and today-60days)? Same question goes for "2 months...

The simple timezone clock function falls into incorrect condition and I have no idea why

javascript,function,time
I implemented a simple timezone clock and it somehow does not change time based on different timezone, after a few debugging I found out it falls to incorrect "if" condition. Here's the code: var zone = "ho"; alert("1"+zone); var ft; var dt = new Date(); var def = dt.getTimezoneOffset()/60; var...

Difference in time is giving Invalid date

javascript,asp.net,time
I have a scenario, where I want to show the total time of employee after calculating the InTime and OutTime from the first two textboxes. Here Is the scenario, In first textbox User will add INTIME In Second textbox User will add OUTTIME. As soon as both the values are...

Android - At Minutes to a Time hh.mm.ss

java,android,date,time
i,ve got a problem which i cant solve at the moment. I already googled for it and found some solutions, but all of them not rly match my problem. So i get 2 Strings from SQL Database in the format hh:mm:ss. The first String is a time, for example "14:30:00"...

After an ETA calculation, date and time not showing correctly. (Whole PHP code) [closed]

php,date,time
Please see the comments within the php. Truck fleet ETA calculator Distances in Kilometers : city a to city b $dist_city_a_city_b = 475; Loading/Preparation time $turnaround = 45; Departure time $departtime = date('Y-m-d H:i:s'); echo "Distance: $dist_city_a_city_b Kilometers<br>"; $distM = $dist_city_a_city_b*1000; echo "Distance: $distM in meters<br>"; Speed constant in Kilometers...

performance.now() vs Date.now()

javascript,time
What is the difference between performance.now() and Date.now()? Should I consider performance.now() as a replacement for Date.now() since performace.now() is more consistent and independent?...

Convert time based on timezone using java.time

java,time,java-8,java-time
How to change the time based on timezone in LocalDateTime, here i have built a date with Time zone as EST, now i need to find the UTC of the corresponding time. please help me how to solve this String str = "16Jun2015_153556"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ddMMMyyyy_HHmmss"); formatter.withZone(ZoneId.of("EST5EDT")); LocalDateTime dateTime...

Javascript how to start script on exact time

javascript,loops,time,setinterval
script will start on exact time (ex: 2015:06:15:00:00) If its on time, it will alert HELLO every 1 second. setInterval(function () {alert("Hello")}, 1000); could you please help me how to make this on up?...

Swift - Convert Milliseconds into Minutes, Seconds and Milliseconds

swift,time,nsdate
I am writing a racing app and want to convert a large number of milliseconds into minutes:seconds.milliseconds (for example, 1:32.361). At the moment I just do it through maths (minutes / 60000), then get remainder and divide further, etc., but i find that it is off every now and then...

GetTime doesn't correctly display zero's

java,time,timestamp
I use TimeStamps in my system. Everything works correctly, however I find it annoying to have [12:2:2] as TimeStamp. Because you don't know if it's 20 or 2. I am tired and sick, and starting to think it is the compiler. java.util.Date date= new java.util.Date(); Timestamp time = new Timestamp(date.getTime());...

Rails: active record saving time:type with unwanted format

ruby-on-rails,ruby,activerecord,time
I have a table call periodo with the attribute hour. i pass my time param in this way hour = Time.parse( splitLine[1] ) #where splitLine[1] is my time but in string periodo = Periodo.new(:hour => hour.strftime("%H:%M")) periodo.save but active record save the records in this way hour: "2000-01-01 07:00:00" ,...

Can someone explain this odd javascript date output?

javascript,date,datetime,time
https://jsfiddle.net/8cvhnwgs/1/ //new Date(year, month, day, hours, minutes, seconds, milliseconds) $("#out").html(new Date(2015, 5, 31, 08, 25, 30, 0)); The date I give is May 31st, but it outputs July First, can someone explain why? Have I used arguments wrong?...

Formatting the Output

python,time
I have developed two algorithms to solve Problem 1 of Project Euler and I was trying to determine which one is faster. So I decided to import the time module, based on one of the suggestions on this site. The running time is about a 1000th of a second. But...

How to Increment variable in java every 24 hours , every week, every month? [closed]

java,date,time,increment
I have 3 variables whose values I want to increment by 1 every 24 hours , every week and every month. The JAVA program will be running continuously during the time period.

Detect when it is evening/night - NSDate - iOS

ios,objective-c,time,nsdate,nscalendar
I have an iOS app. One of the sections of the app shows a simple little weather forecast for a specific location. As part of this forecast, the app also shows some images. The images are either day based, in which case they will have a 'sun' image or night...