Menu
  • HOME
  • TAGS

PHP - Count how many days ago

php,mysql,date,time,count

Step 1 : Remove the Last part of your date i.e., CET or CE $Date = substr($Date, 0, strpos($Date, " ")); It will the character after last spaces Step 2 Find the Difference between current date and the extracted date by $interval = $datetime1->diff($datetime2); And here's the entire code :...

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

python,time,format

Brute force: value = "00:15:47" # taken from csv if value < "00:16:00": # handle smaller values else: # handle bigger values ...

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

php,datetime,time

Why don't you put your condition before conversion? $cur_time = time(); $db_time = $rs[$k]['update_time']; $diff = abs($cur_time - $db_time); if($diff > 3000) // 3600 is 1 hour and 3000 is 50 minutes { $msg = 'greater'; } else { $msg = 'lesser'; } Even if the time difference is 1...

Regex pattern for date and hour

regex,date,time

That's fairly correct, but you can adjust things to make them more realistic. "[0-2]?[0-9]:[0-5][0-9]" would be more realistic for time, as there is no 32:79 and what not. Also, the first can be optional to make 8:00 viable. [0-3]?[0-9]\/[0-1]?[0-9]\/[1-2][0-9][0-9][0-9] for date, as there can be no 42th of april and...

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

javascript,jquery,input,time

Maybe you should link it to the keyup event like here: // ... somewhere in the ON DOM READY section, input has ID "a" $('#a').keyup(function(){var o=$(this);// o: jQuery object referring to the current input setTimeout(function(){ if (o.val().length<5) o.val('');},1000); }) see here: http://jsfiddle.net/1fjyezf7/ . I reduced the minimum length to 5...

Disk read/write perfomance in linux

linux,time,dd

/dev/zero is a special file. It's contents stem from a device driver. All write operations on /dev/zero are guaranteed to succeed. A bit more about that here and here Without specifying of dd prints to stdout. Thus the data which the terminal receives has to be formatted and printed. The...

Use XSLT to convert date time to full words

xml,date,xslt,time,formatting

In XSLT 2.0, you can use the format-date(), format-time() and format-dateTime() functions to format dates and time in a variety of ways, for example: XML <input>2014-04-30T15:45:12</input> XSLT 2.0 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <output> <xsl:value-of select="format-dateTime(input, 'The [DWwo] Day of [MNn] in the Year [YWw],...

Ruby Initialize a Variable to Current Time

ruby-on-rails,ruby,time,updates

You can write after_filter to set the lastPopulation, Like after_filter :set_last_polulated, :only => ['populateTable'] def set_last_polulated @lastPolulation = DateTime.now end ...

Android: Time Loop in milliseconds

android,android-activity,time

You can use timer or thread handler timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { Do your own code ///////schedule the timer, after the first 100ms the TimerTask will run every 1000ms } }, 1000, 1000); Can Use Another handler Handler handler = new Handler(); handler.postDelayed(...

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

time,google-analytics,bounce,rate

That's because the bounce rate refers to entrances (which are two in your screenshot), not to the pageviews. I.e. you have 40 pageviews that did not bounce and viewed the page 1:53 min on average, but for the 2 for whom this was the landingpage and the last (and only)...

R help converting char to POSIXlt

r,datetime,time,strptime,posixlt

I get a similar output when doing > iso = "1/8/2014 10:19:00 PM" > strptime(iso,"%d/%m/%Y %I:%M:%S %p") [1] NA This is due to my default locale (fr_FR) that does not support %p. Changing this locale to "C", solves the problem: > Sys.setlocale(category = "LC_TIME","C") > strptime(iso,"%d/%m/%Y %I:%M:%S %p") [1] "2014-08-01...

String to Time in Javascript

javascript,time

var d = new Date('your_date_string'); var start = Number(d.setHours(0,0,0,0)); var end = Number(d.setHours(23,59,59,999)); //OR var start = d.setHours(0,0,0,0).getTime(); var end = d.setHours(23,59,59,999).getTime(); start and end are your variables See setHours docs here...

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

regex,time

Since milliseconds are allowed only when seconds are present, you should make the optional parts for milliseconds nested inside the optional part for seconds: ^(([0-1][0-9])|([2][0-3])):([0-5][0-9])(:[0-5][0-9](?:[.]\d{1,3})?)?$ Demo....

Convert long int seconds to double precision floating-point value

c++,date,datetime,time,converter

There are 86400 seconds in a day, and 25569 days between these epochs. So the answer is: double DelphiDateTime = (UnixTime / 86400.0) + 25569; You really do need to store the Unix time in an integer variable though. ...

How to prevent MatLab from freezing?

matlab,memory,time,evaluation

Let's answer your questions one at a time: Question #1 - Can I limit the amount of time MATLAB takes to execute a script? As far as I know, this is not possible. If you want to do this, you would need a multi-threaded environment where one thread does the...

How to check if two times overlap in PHP?

php,time,compare,unix-timestamp

Fixed it by changing the algorithm for comparing the times. New version: function testRange($s1, $e1, $s2, $e2) { return $s1 <= $e2 && $s2 <= $e1; } Don't know why this works over the previous one however....

Android-Reduce the time when retrieving data

android,time,httprequest

Google Volley or Square's Retrofit can help for restful communication. If you are pulling down a lot of images also check out Square's Picasso. Also are you pulling down too much data at once. You can look at Lazy Loader methodologies.

Check day of week and time

php,time

your missing 1 more closing ) if (isBetween('22:30','02:00',date('H:i'))){ You can just do like this: function isBetween($from, $till, $input) { $f = date('H:i', strtotime($from)); $fd= date('l', strtotime($from)); $t = date('H:i', strtotime($till)); $td= date('l', strtotime($till)); $i = date('H:i', strtotime($input,'+8 hours')); $id= date('l', strtotime($input)); $days = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); if(array_search($fd,$days)<array_search($id,$days) &&...

How To Compare six time on PHP?

php,time

a >= 1 || a <= 2 is true for all numeric a. Use && Like this: $in1 = $waktu >= $jam1_A && $waktu <= $jam1_B; $in2 = $waktu >= $jam2_A && $waktu <= $jam2_B; $in3 = $waktu >= $jam3_A && $waktu <= $jam3_B; $result = ($in1 || $in2 ||...

Function to calculate values comparing sequential time periods

r,function,time,plyr

You can determine the number of times each site appeared at each time with the table function: (tab <- table(df$time, df$site)) # A B C D E # 1 1 1 1 1 0 # 2 1 1 1 0 0 # 3 1 1 1 1 1 With some...

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

php,time

echo date("Y-m-d H:i:s");//current date echo date("H:i:s");//current time you can search in net before ask:D...

Timing in C with time.h

c,time,time.h

Here's a simple example, compiled on a Ubuntu box: #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <sys/time.h> #include <unistd.h> #include <time.h> int64_t timestamp_now (void) { struct timeval tv; gettimeofday (&tv, NULL); return (int64_t) tv.tv_sec * CLOCKS_PER_SEC + tv.tv_usec; } double timestamp_to_seconds (int64_t timestamp) { return timestamp / (double) CLOCKS_PER_SEC; }...

PLSQL Need REFCURSOR DATE + TIME

date,time,plsql,cursor

The problem here seems to be as follows: You are setting o_besteltijden as a value selected from CAST(v_besteltijden AS t_openingstijd) where v_besteltijden is calculated from to_date t_openingstijd is a table of date type (CREATE OR REPLACE TYPE t_openingstijd IS TABLE OF DATE;). So your answer will be in date format....

Find number of days in Perl

perl,time

Time::Piece has been a standard module in Perl for awhile: use strict; use warnings; use feature qw(say); use Time::Piece; my $date1 = '2015-01-01 10:00:00'; my $date2 = '2015-01-10 11:00:00'; my $format = '%Y-%m-%d %H:%M:%S'; my $diff = Time::Piece->strptime($date2, $format) - Time::Piece->strptime($date1, $format); # subtraction of two Time::Piece objects produces a...

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

android,date,time,parse.com

What I finally did. I used Calender class and filled each item(year, month, day, hour, minute) while using date and time pickers. And used Calendar.getTime method to transform it to Date class that Parse.com understand. Calendar mDateTime = Calendar.getInstance(); ... mDateTime.set(Calendar.YEAR, selectedYear); mDateTime.set(Calendar.MONTH, selectedMonth); mDateTime.set(Calendar.DAY_OF_MONTH, selectedDay); ... meeting.put(ParseConstants.KEY_DATETIME, mDateTime.getTime()); So...

Show a timer in a Java Frame

java,time

You can use this to create a timer: timer = new Timer(speed, this); timer.setInitialDelay(pause); timer.start(); I would put 1000 in speed so that it updates every 1 second, (since the times goes my milliseconds.) Next, I would create a label in your java program: JLabel label = new JLabel("Text Here");...

having issues with python time object

python,date,time

Just use .time(): from datetime import datetime c_time = '2015-06-08 23:13:57' c_time_converted = datetime.strptime(c_time,"%Y-%m-%d %H:%M:%S") print c_time_converted print c_time_converted.time() prints: 2015-06-08 23:13:57 23:13:57 EDIT (addressing a comment regarding datetime) Here is a simple example of using a difference in datetime: from datetime import timedelta c_time_later = '2015-06-08 23:50:21' c_time_later_converted =...

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

javascript,function,time

You have: if (zone = "local") which makes zone take the value of "local". Change to: if (zone === "local") ...

Notification Message Instantly Fired - Android

android,time,notifications,broadcastreceiver,alarmmanager

Try replacing aManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent); with aManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+calendar.getTimeInMillis(), pIntent); ...

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

java,android,date,time

First, a 'time' without a date is not valid. Think about daylight saving time etc. One solution is maybe to create two date objects (with a fixed date) and use them for your calculation. Or parse the string and use TimeUnit to work with the values. Keep in mind that...

Time stamp missing

c#,time,serial-port

Basically, I was wrong by saying that the time stamp is originally included in the data i received.. I need to add in the time stamp on my own.. This was to act as a record of when did i actually received the following data. As a result, what's missing...

Difference in time is giving Invalid date

javascript,asp.net,time

To subtract start from end, you have to convert both of them to dates first. Change your JavaScript function: function TimeCalculation() var start = $('#txtInTime').val(); var startHours = parseInt(start.split(":")[0]); var startMins = parseInt(start.split(":")[1]); var end = $('#txtOutTime').val(); var endHours = parseInt(end.split(":")[0]); var endMins = parseInt(end.split(":")[1]); var diffHours = endHours -...

Convert double to time_t

c++,time,standards,chrono,time-t

The type of std::time_t is unspecified. Although not defined, this is almost always an integral value holding the number of seconds (not counting leap seconds) since 00:00, Jan 1 1970 UTC, corresponding to POSIX time. So, just a safe casting between them could be fine. Also be carefull about portability...

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

sql,oracle,time,difference

Get the previous timestamp using lag(). The rest is just basic querying: select acct_number, trunc(LOG_EVENT_TMST) from (select cl.*, lag(log_event_tmst) over (partition by acct_number order by log_event_tmst) as prev_let from customer_log cl where LOG_EVENT_TMST > to_date('03/01/2015 00:00:00','MM/DD/YYYY HH24:MI:SS') ) cl where (log_event_tmst - prevlet) < 1.0 / (60 * 24) group...

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

php,string,date,time

Well since you have some weird characters at the end of your date string, you could just use sscanf() combined with vprintf() to only grab hours and minutes from it and display it in your desired format: $str = "0:18:32:���"; vprintf("%02d:%02d", sscanf($str, "%d:%d")); output: 00:18 ...

Teradata Convert DATE to midnight

date,time,teradata

When you cast a date to a tamestamp it's set to midnight, then you can add or subtract an interval: -- tomorrow minus a millisecond CAST(CURRENT_DATE +1 AS TIMESTAMP(3)) - INTERVAL '0.001' SECOND -- or today plus almost 24 hours CAST(CURRENT_DATE AS TIMESTAMP(3)) + INTERVAL '23:59:59.999' HOUR TO SECOND ...

Repeat a sound/action every certain time

python,date,time,while-loop,repeat

Your logic is wrong. First of all, the while loop will most likely end in the first iteration and you want the program to continue till you tell it to. In addition to that, you don't update the now variable inside the loop, which is basically a bad idea. For...

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

php,date,time

Take departure time, add travel time in seconds, and then format it: echo "Arrival Time: " . date('Y-m-d H:i:s', strtotime($departtime) + $arivaltime * 60) . " (ETA)<br>"; I would rename many variables to make more sense out of it. $eta_1 -> $travel_seconds $arivaltime -> $travel_minutes ...

Operators suddenly not working

time,vbscript,operators

You are comparing values of time and string data subtype. The Comparison Operators (VBScript) reference is quite bit unclear about it (or about automatic data subtype conversion); I guess conversion time to string with an alternative leading zero manipulation, for instance #09:10:12# time converts to either "9:10:12" or " 9:10:12"...

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

php,date,datetime,time

this should work : $date="Wed May 20 06:37:57 +1000 2015"; $datetime = DateTime::createFromFormat('D F d H:i:s O Y',$date); echo $datetime->format('Y-m-d H:i:s'); and if you want to convert-it to british timezone : $datetime->setTimezone(new DateTimezone('Europe/London')); echo "Queen's datetime: ".$datetime->format('Y-m-d H:i:s') ...

Detect when it is evening/night - NSDate - iOS

ios,objective-c,time,nsdate,nscalendar

Just in case you are allowed to use Weather API. You can use the following library: OpenWeatherMapAPI It gives the data in the following format: NSDictionary that looks like this (json): { coord: { lon: 10.38831, lat: 55.395939 }, sys: { country: "DK", sunrise: 1371695759, // this is an NSDate...

Response Time Accuracy

python,time,python-3.4,psychopy

Python's time functions are not the limiting factor here. Depending on your particular computer and OS, you can get microsecond resolution (subject to all sorts of caveats about multitasking and so on). The real issue is hardware. There is no point worrying about millisecond time resolution if you are collecting...

Batch - xcopy files older than x minutes

batch-file,time,copy

Check the FileTimeFilter.bat - it is capable to filter files by different time conditions.So (it should be in the same directory): @echo off for /f "tokens=* delims=" %%# in (' call FileTimeFiler.bat "New" -mm -20 -direction before -filetime created ') do ( copy "%%~f#" "Target" ) EDIT . Filter txt...

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

mysql,date,time

One important thing to note here is that not all months are 30 days, so instead of using INTERVAL DAY use INTERVAL MONTH. Next, you don't need to use the subtraction sign for dates, you can use the DATE_SUB() function which will do what you need. Last, keeping those things...

Convert Epoch timestamp to date format

datetime,time,epoch

Since you have 10-digit numbers as the created time, you're probably using 'Unix timestamps', which count seconds since The Epoch, which is 1970-01-01 00:00:00 +00:00 (midnight on the morning of 1st January 1970 in the UTC or GMT time zone). If you had 13-digit numbers, it would probably be milliseconds...

12 Hour Clock Array Sort

php,arrays,sorting,time,clock

strtotime will accept that format. So you can use a custom sort (usort) with a strtotime based callback. usort($array, function($a, $b) { return (strtotime($a) > strtotime($b)); }); ...

Parsing a timestamp with time zone [duplicate]

java,parsing,date,time,timestamp

Just use X to indicate ISO 8601 time zone: new SimpleDateFormat("yyyy-MM-dd HH:mm:ssX").parse("2015-05-21 12:38:00Z")...

PHP Timezone not working correctly

php,date,time,timezone

You're not quite handling timezones correctly // set the datetime in the EDT timezone $schedule_date = new DateTime("2015-06-22 13:00:00", new DateTimeZone("America/New_York") ); echo $schedule_date->format('Y-m-d H:i:s T'). " <br />"; // 2015-06-22 13:00:00 // change it to CDT $schedule_date->setTimeZone(new DateTimeZone('America/Chicago')); echo $schedule_date->format('Y-m-d H:i:s T'). " <br />"; // 2015-06-22 12:00:00 Demo...

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

java,loops,time,while-loop

Try System.nanoTime() since you are not measuring time since the epoch. System.currentTimeMillis vs System.nanoTime

Time format conversion with PHP

php,time

<?php $duration="1H10M5S"; $display=str_replace(array('H','M','S'), array(' Hour(s) ',' Minute(s) ',' Seconds'), $duration); echo $display; Output 1 Hour(s) 10 Minute(s) 5 Seconds Fiddle...

time formatting in matlab

matlab,time,format

You can use a function like strrep or regexprep to get rid of the colon in the string. For example: t = {'"8:59"', '"9:00"', '"9:01"', '"9:02"'}; newt = strrep(t, ':', ''); newt = strrep(newt, '"', ''); newt = strrep(newt, ''', ''); Or the slightly bizarre regexprep call: newt = regexprep(t,...

How to convert date into timeago

javascript,html5,time,timeago

My problem is that the result of datetime is [object Text] Well, yes, because you tell JavaScript to do that: timeTag.setAttribute("datetime",document.createTextNode(message.date)); Try timeTag.setAttribute("datetime", message.date); Attribute values are strings, whereas DOM nodes (including text nodes) are objects....

Swift - generate random Integer between 0.1 and 0.6

ios,swift,time,int,delay

Okay here is the working code - thanks to @mireke for help // delay before playing var lower : UInt32 = 1 var upper : UInt32 = 6 var delayTime = arc4random_uniform(upper - lower) + lower var delayTimer = Double(delayTime) / 10 var delay = delayTimer * Double(NSEC_PER_SEC) var time...

Javascript time differs from Java time

java,javascript,servlets,time

Since you are running on a windows machine the Java call to get the time is rounded to the nearest 16 milliseconds. The Javascript call in not restricted to this limitation. With this knowledge it is quite easy for one to be different, and out of order, to the other....

Bash variable expansion can't be combined with time command

linux,bash,shell,time

The data in $timer is split on $IFS (spaces), and used as separate arguments. It is not expanded and then evaluated as bash code. Your command $timer ls is therefore equivalent to: "/usr/bin/time" "-f" "'elapsed time:" "%E'" "--" "ls" The correct way to do this in your case is using...

Using Master theorem to calculate asymptotic time complexity of algorithm

algorithm,time,complexity-theory,master,theorem

Every time you solve a subproblem, you have to divide the current instance into more subproblems (cost = 100 steps). Then, you have to merge the results of the subproblems (cost = 75n steps). That means f(n) = 75n + 100 because f(n) represents the cost of solving a single...

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

android,date,time,picker

Try this: Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 2); dp.setMinDate(cal.getTimeInMillis()); // where DatePicker dp ...

Select By Time And Date [closed]

mysql,sql,date,time

http://sqlfiddle.com/#!9/2e783/1 SELECT * FROM test WHERE date_time <= TIMESTAMP('2015-12-15 12:00') - INTERVAL 28 HOUR ...

Format Date VARIABLE to short date VBA

vba,date,time

Please, see: Format function. Usage: 'UserForm has a TextBox named TxtDate Dim myDate As Date, sDate As String myDate = Me.TxtDate 'DateSerial(2014,12,11) sDate = Format(myDate, "Short Date") 'or sDate = Format(myDate, "yyyy/MM/dd") ...

Convert time based on timezone using java.time

java,time,java-8,java-time

This answer might be somehow more structured than the correct answer of Jon Skeet. In my comment above I have also pointed out not to overlook the immutable nature of DateTimeFormatter so please always assign the result of any method prefixed by "with...()" to a variable of same type. //...

Echo of time not displayed at end of batch file

batch-file,time,echo

ffmpeg32 never returns. Add a START or CALL infront of this line. Add a REM in front of this line just to see if the batch is executed to the last line. Also the last line is wrong. Another clue it's just not executed completly. You would get an error...

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

javascript,time

Check out Date.parse() Date.parse('06/12/2015 12:00 PM'); ...

GetTime doesn't correctly display zero's

java,time,timestamp

Have a look at the DateFormat or SimpleDateFormat class. SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); df.format(new Date()); ...

Subset a dataframe based on time variable

r,date,datetime,time,subset

You can change the 'Time' column to 'POSIXct' class and then subset datasubcolrow$Time <- as.POSIXct(datasubcolrow$Time, format='%d/%m/%Y %H:%M:%OS') subset(datasubcolrow, Time < as.POSIXct('15/05/2015 13:30:15.417', format='%d/%m/%Y %H:%M:%OS')) data datasubcolrow <- structure(list(Time = c("15/05/2015 13:30:07.291", "15/05/2015 13:30:08.307", "15/05/2015 13:30:09.323", "15/05/2015 13:30:10.338", "15/05/2015 13:30:11.354", "15/05/2015 13:30:12.370", "15/05/2015 13:30:13.386", "15/05/2015 13:30:14.402", "15/05/2015 13:30:15.417",...

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

php,date,time

http://php.net/manual/en/function.date.php Second parameter of date function should be in Unix Time Stamp format....

how extract real time form time.gov in python?

python,time,ntp

Use urllib to retrieve http://time.gov/actualtime.cgi that returns something like this: <timestamp time="1433396367767836" delay="0"/> Looks like microseconds >>> time.ctime(1433396367.767836) 'Thu Jun 4 15:39:27 2015' ...

Multiplication of a time in PHP

php,time

Here is what you should do Step 1 : Convert your hours into seconds $seconds = strtotime("1970-01-01 $maritime UTC"); Step 2 : Multiply it directly $multiply = $seconds * 5; Step 3 : Convert the seconds back to hours, And you're done ! echo gmdate("d H:i:s",$multiply); So Your final code...

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

android,time,textview

Tell me if I understand you currectly, you dont want to make your textview inside an any activity, because you want to use it in all the life circle of the application? So if im understand you currect you want the application context. Then you can retrievegetResources() Im hope im...

Swift - Convert Milliseconds into Minutes, Seconds and Milliseconds

swift,time,nsdate

You can create a NSTimeInterval extension to format your elapsed time as follow: extension NSTimeInterval { var minuteSecondMS: String { return String(format:"%d:%02d.%03d", minute , second, millisecond ) } var minute: Int { return Int((self/60.0)%60) } var second: Int { return Int(self % 60) } var millisecond: Int { return Int(self*1000...

How to stub Time.now.hour

ruby-on-rails,testing,time,rspec,stubbing

Another approach would be to use Timecop (or the new Rails replacement travel_to) to stub out your time for you. With Timecop you can have super readable specs with no need for manual stubbing: # spec setup Timecop.freeze(Time.now.beginning_of_day + 11.hours) do visit root_path do_other_stuff! end ...

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

time,smallbasic

In gross terms, you need a date based upon an epoch, not the day of the month. IOW, count the number of days since an event, store that value, when the current date is 7 days after the original date, expire. http://litdev.co.uk/ offers a smallbasic library that provides this functionality...

performance.now() vs Date.now()

javascript,time

They both serve different purposes. performance.now() is relative to page load and more precise in orders of magnitude. Use cases include benchmarking and other cases where a high-resolution time is required such as media (gaming, audio, video, etc.) It should be noted that performance.now() is only available in newer browsers...

Perform a task each interval

java,time,schedule

1) Create ScheduledExecutorService ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); 2) Create and schedule your Runnable: Runnable task = new Runnable() { @Override public void run() { System.out.println("Done:" + new Date(System.currentTimeMillis())); // some long task can be here executor.schedule(this, 10, TimeUnit.SECONDS); } }; //can be 0 if you want to run it fist...

Timer in Python(simultany)

python,time

very easy but not so sophisticated way is to write: import time start_time = time.time() at the beginning of your code and at the end print "run time (s):", time.time() - start_time Note that in this solution the output time may be influenced by other processes running simultaniously on your...

Javascript update time function causes high CPU

javascript,performance,date,time

Use setTimeout instead of setInterval. The comments above have done a good job explaining why, but I'll reiterate. Your current function will schedule a new setInterval every time it is called, on top of any existing ones. After just 5 seconds you'll have 32 intervals running. Every second this number...

Android: automatic logout

java,android,time,login,logout

Set Alarm: Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, "YourTimeinMinutes"); // you can use Calendar.Seconds etc according to your need Intent intent = new Intent(YourActivity.this, AlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(YourActivity.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Get the AlarmManager service AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); AlarmReceiver.class public class...

Is timezone info redundant provided that UTC timestamp is available?

datetime,time,timezone,timestamp,timestamp-with-timezone

For a single event, knowing the UTC instant on which it occurs is usually enough, so long as you have the right UTC instant (see later). For repeated events, you need to know the time zone in which it repeats... not just the UTC offset, but the actual time zone....

Can someone explain this odd javascript date output?

javascript,date,datetime,time

The month parameter to the Date constructor is 0 indexed, so 5 is June, which only has 30 days.

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

java,date,time,increment

Do you need the variable? You could do it without counting: LocalDate today = LocalDate.now(); LocalDate startDay = LocalDate.of(1960, Month.JANUARY, 1); Period p = Period.between(startDay, today); long days = ChronoUnit.DAYS.between(startDay, today); long weeks = ChronoUnit.WEEKS.between(startDay, today); long months = ChronoUnit.MONTHS.between(startDay, today); ...

Why is Array.splice() so slow?

javascript,arrays,performance,time

There is a fallacy in that benchmark: .splice preserves the order of the elements in the array, and therefore needs to move half of the elements until the hole created by the removal is sifted up to the end and can be removed by resizing the array. It follows that...

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

algorithm,matlab,time,big-o,nested-loops

As @horchler suggested you need to preallocate the target array this is because your program is not O(N^4) without preallocation each time you add new line to array it need to be resized so new bigger array is created (as matlab do not know how big array it will be...

Ruby - Convert formatted date to timestamp

ruby,date,time,timestamp

Your date string is in RFC3339 format. You can parse it into a DateTime object, then convert it to Time and finally to a UNIX timestamp. require 'date' DateTime.rfc3339('2015-05-27T07:39:59Z') #=> #<DateTime: 2015-05-27T07:39:59+00:00 ((2457170j,27599s,0n),+0s,2299161j)> DateTime.rfc3339('2015-05-27T07:39:59Z').to_time #=> 2015-05-27 09:39:59 +0200 DateTime.rfc3339('2015-05-27T07:39:59Z').to_time.to_i #=> 1432712399 For a more general approach, you can use DateTime.parse...

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

java,time,clock

These systems generally rely on a Real Time Clock. This is a hardware device that uses a quartz crystal, that keeps track of time, and often draws next to no current, and can remain counting on nothing more then a button cell for a few years. Devices like GPS location...

Javascript how to start script on exact time

javascript,loops,time,setinterval

I'd use the getTime object in JS I believe I have the time set right in this JSFiddle var d = new Date(); var year = d.getFullYear(); // Month 0 = January | Month 11 = December | so I changed vallues by +one var month = d.getMonth() +...

convert time to to 12 hour by manipulate string

javascript,jquery,datetime,time

Solution based on your code: function formatDate(raw_date){ var year = raw_date.substring(0,4); var month = raw_date.substring(5,7); var day = raw_date.substring(8,10); var right = raw_date.substring(10); var hours = ((right.substring(0,3))% 12 ); var min = raw_date.substring(14,16); var suffix = right.substring(0,3) >= 12 ? "PM":"AM"; return day + "/"+month+"/"+year+" "+hours + ':' + min...

Compare multiple server times to localtime

bash,shell,date,time,scripting

Try something like this: #!/bin/bash servers="server1.... server2...." seconds="3" # value for servers to differ (in seconds) for server in $servers do difference=$(echo $(ssh -l root ${server} "( date +%s )") "-" $(date +%s) | bc) if [[ ${difference#-} -le ${seconds} ]] ; then echo $server - IN SYNC else echo...

Formatting the Output

python,time

You've made a mistake in how to apply string formatting. Try this: print('The running time is %.5f'%(time.time()-start_time)) ...

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

python,multithreading,events,time,condition

There are several ways -- some are more easily portable to different operating systems than others. Generally, what you could do is: spawn a new thread for every task in each thread, get the current time, and time.sleep() for the remaining time That works, but it's not extremely accurate. You...

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

python,image-processing,time,delay

ummm .... you need basic math here time.sleep(delay-(time.time()-start)) ...

How to use TIME type in MySQL?

mysql,time

I solved, I entered TIME without parentheses. I thought that the type TIME required an input parameter. CREATE TABLE IF NOT EXISTS CookingDB.Recipe ( ... CookingTime TIME NULL, ... ...

Performance measures : Java vs JavaCard [closed]

java,performance,time,smartcard,javacard

You run the algorithm is in two different platform, so the final machine language is not the same.

Rails: active record saving time:type with unwanted format

ruby-on-rails,ruby,activerecord,time

Date formats are only valid within your application, not within the database - they are only responsible for the way time objects are displayed to your users and will not affect the way data is stored. Unfortunately, there is no such a concept like time only in the database (at...

DateTimeFormatter - parsing string with time zone

java,time

So, you have a java.util.Date object, which represents a precise instant on the time-line. And to transform it into a LocalDateTime, you're transforming the Date into a String, and then parse the String. That's a bad strategy. You shouldn't do that. Just use the date transformation methods: LocalDateTime localDateTime =...

What is this Time Format 1381039499

time

According to this site, that is the Unix timestamp for: Sun, 06 Oct 2013 06:04:59 GMT. Most programming languages have a function to convert to/from Unix timestamps, but the correct way to do this will obviously vary between them....

How to Minus time with python

python,time

You can use time delta like this: import datetime print datetime.datetime.now() - datetime.timedelta(minutes=59) ...

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

java,loops,for-loop,time

you set t1 only once, t2 3 times, and t3 around 1000 times. you compare t1 with the last time you set t2. you compare the last time you set t2 with the last time you set t3. the first comparison shows you the combined runtime of the inner loops...

Set LocalDateTime to autogenerate with hibernate 4.3.10

java,hibernate,time

You could use the @PrePersist annotation. Executed before the entity manager persist operation is actually executed or cascaded. This call is synchronous with the persist operation. Example: @PrePersist protected void onCreate() { createdAt = new LocalDateTime(); updatedAt = new LocalDateTime(); } And if you deem it fit you also have...

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

php,time,logic,strtotime

This should work for you: First convert all strings into timestampes, by looping through all values with array_map(). After this you can simply loop through your values and check if they are in a 15 minute range. <?php $t = "0430"; $timeArray = array('0400', '0415', '0420', '0430', '0440', '0450', '0500',...

Changing div style for every day of the week script

javascript,css,time

One approach is: function colorToday(color) { // get all the <p> elements contained within <div> elements // with the class-name of 'dayname', using // document.querySelectorAll(); converting the NodeList // into an Array, using Functionn.prototype.call() to use // Array.prototype.slice(): var dayContainers = Array.prototype.slice.call(document.querySelectorAll('div.dayname p'), 0), // JavaScript's days of the week...