w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Calculate number of days,hours,minutes,seconds only working hours
Forget about date(), strtotime(), time(), etc. function, use DateTime : Use example : $from = '2013-09-06 15:45:32'; $to = '2013-09-14 21:00:00'; echo some_func_name($from, $to); Output : 1 day, 22 hours, 14 minutes, 28 seconds Function : function some_func_name($from, $to) { $workingDays = [1, 2, 3, 4, 5]; # date format = N $workingHours = ['from' => ['08', '00'], 'to' => ['17', '00']]; $start = new DateTime($from); $end = new DateTime($to); $startP = clone $start; $startP->setTime(0, 0, 0); $endP = clone $end; $endP->setTime(23, 59, 59); $interval = new DateInterval('P1D'); $periods = new DatePeriod($startP, $interval, $endP); $sum = []; foreach ($periods as $i => $period) { if (!in_array($period->form

Categories : PHP

how to convert python hours to regular hours
print(datetime.now().strftime('%Y-%m-%d %I:%M:%S %p')) will print: 2013-06-18 09:47:38 PM Look at the documentation to find all directives.

Categories : Python

Cannot get hours to total over 24, eg 48 hours in hh:mm:ss output
SELECT USERNAME, CAST(TotalTimeInSeconds / (60 * 60) AS Varchar) + ':' + CAST(TotalTimeInSeconds % (60 * 60) / 60 AS Varchar) + ':' + CAST(TotalTimeInSeconds % (60) AS Varchar) AS TotalHours FROM #TotalSessionTime If you want minutes and seconds to always be two digits, you'll have to left pad them, which would make for an ugly example, but would work fine.

Categories : Sql Server

How to run crontab for every 36 hours
I don't think you can specify further than 24 hours. You could have it run every hour, and each time it hits have it increment a var stored in a database or file, then when that var hits 36 run the script and reset it to 1. EDIT: on the same note you could have it run every 12 hours and have it increment by 12 for example : $var = (int) file_get_contents('count.txt'); $var++; if($var === 36) { //run script //update count.txt }else { //update count.txt die(); }

Categories : PHP

ICS URL outputting 5 hours behind
In the line below add X-WR-TIMEZONE:America/New_York $data = "BEGIN:VCALENDAR VERSION:2.0 METHOD:PUBLISH X-WR-TIMEZONE:America/New_York UPDATE: i have updated the whole line of code, its using DTSTART;VALUE=DATE: with out the Z and the same for DTEND $data = "BEGIN:VCALENDAR VERSION:2.0 METHOD:PUBLISH X-WR-TIMEZONE:America/New_York BEGIN:VEVENT DTSTART;VALUE=DATE:".date("YmdTHis",$start)." DTEND;VALUE=DATE:".date("YmdTHis",$end)." LOCATION:".$location." TRANSP: OPAQUE SEQUENCE:0 UID:".$uid." DTSTAMP:".date("YmdTHis")." SUMMARY:".$name." DESCRIPTION:".$description." PRIORITY:1 CLASS:PUBLIC END:VEVENT END:VCALENDAR";

Categories : PHP

Why is DATE_FORMAT() in php a few hours behind?
If you turn E_NOTICE on, you'd probably work this one out as it chucks up notices if you use date/time functions without setting the time zone. bool date_default_timezone_set ( string $timezone_identifier ) E.G: <?php date_default_timezone_set('America/Los_Angeles'); http://www.php.net/manual/en/function.date-default-timezone-set.php

Categories : PHP

How to know if now time is between two hours?
Calendar cal = Calendar.getInstance(); //Create Calendar-Object cal.setTime(new Date()); //Set the Calendar to now int hour = cal.get(Calendar.HOUR_OF_DAY); //Get the hour from the calendar if(hour <= 23 && hour >= 8) // Check if hour is between 8 am and 11pm { // do whatever you want }

Categories : Java

Checking if its been 24 hours
Is this called by something or is this something that needs to be ran once every 24 hours? If Possible you can just sleep it. I'll need a code example to show you how to fit it in but. In case of once a day On a Schedule Get Time at start of method. Perform Method Get New Time Get Difference in Start Time and Current Time Sleep the remainder of the time until same start time of the next day. OR Need to check before Performing Get Time at start of method save to variable Every time this method is called check a difference in a value say Minutes(see below) If it is greater than 24 then repeat the method Date Diffs can be done like this: Date lasttimeran = null; Date now = null; long diff = now.getTime() - lasttimeran.getTime(); long diffMinutes = diff / (60 * 1000); //If block to check

Categories : Java

Using currentTimeMillis and it's 6 hours off
This is a time-zone related issue. The Calendar class defaults to your local time zone whereas the method System.currentTimeMillis() returns (as specified in the Javadoc): the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

Categories : Java

How to set PHP session to last for four hours?
Where are your session files stored? If it's shared with other applications, those other applications' session lifetime settings also apply to you. Set session.save_path to directory which only your application will use. I would keep session.cookie_lifetime to default: until the browser is closed.

Categories : PHP

Whenever running every 2 hours
Have you tried official docs? Add (or create that file if it doesn't exist) to config/schedule.rb: every 2.hours do #your task here end Or use raw cron syntax, somthing like that should be fine: every '45 */2 * * *' do #task end This should run job every two hours at xx:45, i.e, 00:45, 2:45, etc.

Categories : Ruby On Rails

How to add hours to string in linux?
Something like this can make it. Note the use of date -d" some date " and then the fact that we do + 3 hours. tr -s ' ' squeezes the spaces. cut -d ' ' -f4- gets from the 4th field up to the end. $ who -b system boot 2013-09-13 10:19 $ date -d"$(who -b | tr -s ' ' | cut -d ' ' -f4-) +3 hours" Fri Sep 13 10:19:00 CEST 2013

Categories : Linux

Timer every 24 hours at a certain time
I think the better solution to make the time trigger every second and check the time and any thing you want , I dont think it is expensive process to trigger it every second . trigirring it every 24 hour is not the normal use of timer

Categories : C#

Parse timestamp to get hours
SELECT FROM_UNIXTIME(timestamp,"%h:%i %p") FROM myTable %h = Hour (01..12) %i = Minutes, numeric (00..59) %p = AM or PM Reference: MySQL

Categories : Mysql

Time average in hours
Try this, $total_time=0; foreach($time as $t){ $total_time+=strtotime($t)-1373241600; } So $total_time will be an integer number and you can divide it with 3600 and with count($time) to get average hour :) $average_time = ($total_time/count($time))/3600;

Categories : PHP

Plotting a list of hours
You can use the xticks command to do so. See the following snippet - >>> listHours = ['00:00:000-10:00:000', '10:00:000-20:00:000', '20:00:000-30:00:000','30:00:000-40:00:000', '40:00:000-50:00:000', '50:00:000-00:00:000'] >>> listNumbers = ['0.01', '0.02', '0.03', '0.05', '0.05', '0.03'] >>> listNumbers = [float(elem) for elem in listNumbers] # Convert to a list of floats. >>> plt.plot(listNumbers) >>> plt.xticks(range(len(listHours)), listHours, size='small') >>> plt.show() It gives you a figure like this

Categories : Python

Woocommerce / Wordpress - Out Of Hours
You could use the Catalog Visibility Options extension which allows you to disable the cart. Sadly, you would have to manually turn it on / off during the day for it to work. You would probably want something more automated.

Categories : PHP

Total work hours
Since you only want the first entry per employee-day-action: SELECT [log_date], [emp_id], [emp_name], [1] AS [first_log_in], [4] AS [first_log_out], DATEDIFF(minute,[1],[4])/60.0 AS [hours] FROM @tblLogs PIVOT(MIN(log_time) FOR log_action IN ([1],[4])) p This assumes your log data is in good shape. If you need to check for punchout-before-punchin or multiple punchins before punchout, that's a whole different question.

Categories : SQL

How to update the app every 24 hours in objective c
It can be done only when your app is open(Foreground) using UILocalNotifications which can be used to fire an event after a duration and you can update your database. But if app is not opened you can not perform changes in database. because apple doesn't allow to make changes in database when application is inactive. Check this link : Which type of services can be used if app is in background mode

Categories : Iphone

Highcharts: X-axis off by 2 hours
this might be a time zone issue highcharts by default assumes timestamps are supplied in UTC you may try to using Highcharts.setOptions({ global: { useUTC: false } }); this would make highcharts display data in your browsers timezone

Categories : Javascript

SQL select query by hours
Consider creating an 'hours' table with a row for each hour. Then do a LEFT JOIN to get all the hours represented. Hours rows without records will be returned as NULL but you can COALESCE those if you prefer zero instead of null.

Categories : SQL

MS SQL Entries that expire after 24 hours
You need to use SQL Agent. The logic could be a SQL Agent job that is fired every 24 hours that deletes any data that has a datetime less than DATEADD(d,-1,getdate()). Please do some research on how to implement SQL Agent. If you need help with the code to delete data in a table based on a datetime value, please open a new question that includes that table's schema.

Categories : PHP

Display hours in FullCalendar
What you need are the agendaWeek and agendaDay views (see here). These are set in the header like so (you can add/omit/move buttons as appropriate): header: { left: 'prev,next title today month,agendaWeek', right: '' }

Categories : Jquery

Get weekday hours between two dates?
Not that this will be the most efficient method, it will work for what you require. var end = DateTime.Now; var start = end.AddDays(-100); var weekend = new[] { DayOfWeek.Saturday, DayOfWeek.Sunday }; var count = Enumerable.Range(0, Convert.ToInt32(end.Subtract(start).TotalHours)) .Count(offset => !weekend.Contains(start.AddHours(offset).DayOfWeek)); It might be worth putting a check that the number of hours isn't too big for an int. However this would mean a date range of > 245,000 years!

Categories : C#

Add hours in countdown timer
Here is one Countdown Timer for you http://keith-wood.name/countdown.html It has hours minutes and seconds. You can set a date to where to do the countdown to and isn't hard to use if you read the documentation. simple usage: but when you want more settings i suggest to read the whole documentation $(selector).countdown()

Categories : Jquery

Tracking work hours through git
You can use Assembla Space with (at least) Git repository (Assembla's or Github's or Bitbucket's) and Time Tool (and specially formatted Git's commit message) and get integrated by custom period time-reports from Time Tab. Anyway, time tracking for every single commit is your own task - nobody knows, how much you really work between two consecutive commits

Categories : GIT

R: Matching hours by dates
You can use ddply from plyr package for that: install.packages("plyr") library(plyr) ddply(mydata,.(Date,Hour),transform,mean.value=mean(value) Note: I am assuming that you want the match to find out the mean/median/sum etc of another column called as value. Also, Date need to be formatted as as.Date() before using above function.

Categories : R

select records with date in the last 24 hours
You already have a lower limit on the date, but since your table can have future dates you also need an upper limit. This should work: SELECT * FROM my_table WHERE date > DATE_SUB(NOW(), INTERVAL 24 HOUR) AND date <= NOW()

Categories : Mysql

Display 24 hours in a dropdown list using php
Why not just use strtotime and date? date("h.iA", strtotime($i . ":00")) See a demo Working it into your example, <?php for($i = 0; $i < 24; $i++): echo "<option value="$i">" . date("h.iA", strtotime($i . ":00")) . "</option> "; endfor; ?> Alternatively, <?php for($i = 0; $i < 24; $i++, $d = date("h.iA", strtotime($i . ":00:00"))) { echo "<option value="$i">$d</option> "; } ?> Lastly, for($i = 0; $i < 24; print "<option value="$i">" . date("h.iA", strtotime($i . ":00:00")) . "</option> ", $i++); See a demo

Categories : PHP

How to call a jquery function once every 24 hours?
JQuery doesn't have a built in cookie handler, but its really not that hard in regular js. As @Tim has mentioned this is bad user-experience design, you shouldn't annoy people with popups like that. Once is enough. But I understand why you might want to make sure it doesn't pop-up everytime. If you want to, you can set the date to a VERY far-future date to help prevent it from showing up again, until the user clears there cookies that is. Set the cookie like this function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } And retrieve it like this. function getCookie(c_name) { var c_value = document.cookie; var

Categories : Jquery

Set a content depending the hours or dates in php
You need to compare the results of what time it is against a constant. If I understand you right, a guidance solution is this, but a full solution is not possible for me without more detail or a translation: if (intval(date('H')) < 12) { echo "Erick doesn't start work until 12"; } elseif (intval(date('H')) > 14) { echo "Erick has gone home sick"; } else { echo "Erick is on lunch"; }

Categories : PHP

How to get a SUM of a DATEDIFF but provide cut-off at 24 hours IF a single day is specified
You'll want a conditional SUM, using CASE. Not sure of syntax for your db exactly, but something like: , SUM (CASE WHEN TIME_TO_SEC(TIMEDIFF(re.time_end, re.time_start))/3600 > 24 THEN 0 ELSE TIME_TO_SEC(TIMEDIFF(re.time_end, re.time_start))/3600 END)'Total Time in Hours'

Categories : SQL

How to add hours to current date in SQL Server?
DATEADD (datepart , number , date ) declare @num_hours int; set @num_hours = 5; select dateadd(HOUR, @num_hours, getdate()) as time_added, getdate() as curr_date

Categories : Sql Server

Display hours per hour in GraphView?
You shoud use SimpleDateFormat for date formatting: SimpleDateFormat hoursDateFormat = new SimpleDateFormat("h.mm"); for (int i=0; i<size; i++) { data[i] = new GraphViewData(hoursDateFormat.format(now+(i*60*60*24*1000)), rand.nextInt(20)); // next day }

Categories : Android

Convert TIMEDIFF to hours plus minutes
I think you are looking for: $query="UPDATE `FlightSchedule` SET delay = CEIL((UNIX_TIMESTAMP(time1) - UNIX_TIMESTAMP(time2))/60) WHERE `flightNum_arr`='".$flightNum_arr."';"; Alternatively, there is TIME_TO_SEC function - and, since it provides result in seconds, you'll need to divide it to 60 too.

Categories : PHP

MySql 24 hours intervals select
Use the following SQL-query: SELECT *, TIMESTAMPADD(HOUR, 12, DATE(TIMESTAMPADD(HOUR, -12, created))) AS grp FROM table ORDER BY created DESC This puts the most recent added users on top. You can change DESC to ASC if you want the oldest users on top. Also, what I've added is a grp column. It will help you use grouping in PHP. The result from that column is f.e. August, 24 2013 12:00:00+0000. Whenever this value changes, you need to create a new group header in PHP. Now, I could provide you with some code, but it's dependent on what sort of database-access you're using (mysqli_*-functions or PDO), so I won't go into much detail about that. What I can provide is a link for you containing more information on grouping records using a while loop, which has been provided as an answer to a

Categories : Mysql

php output hours based on locale
This works: (tested) date_default_timezone_set('America/Los_Angeles'); setlocale(LC_TIME, "en_US"); $times = array( '00:00:00', '01:00:00', '02:00:00', '03:00:00', '04:00:00', '05:00:00', '06:00:00', '07:00:00', '08:00:00', '09:00:00', '10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00', '15:00:00', '16:00:00', '17:00:00', '18:00:00', '19:00:00', '20:00:00', '21:00:00', '22:00:00', '23:00:00' ); foreach( $times as $time ){ echo strftime("%X", strtotime($time)) . " "; }

Categories : PHP

Get Hours for multiple venues on foursquare API
Each venue must be queried individually. You can use the multi endpoint to make multiple queries in one HTTP request.

Categories : Api

How to compare time (only hours) in JavaScript?
One thing you should definitely do is simplify the code. Instead of the repeated formatting code, you can combine those blocks into a single function: function formatDate( date ) { return [ date.getDate(), date.getMonth() + 1, date.getFullYear() ].join('/') + ' ' + [ date.getHours().padLeft() ] + 'HKT'; } Then we can define the test variables without any complication: var dateWarn = new Date( 2013, 6-1, 30, 4 ), dateReport = new Date( 2013, 6-1, 30, 3 ); Then, to compare them and get the later date, you can compare the Date objects directly, as you're already doing: var dateLatest = dateWarn > dateReport ? dateWarn : dateReport; Or, another way to do it is to use Math.max() on them. This converts them to numbers and returns a number,

Categories : Javascript

Adjusting time 4 hours behind in SQL query
You can use DATEADD() to adjust TIME: DATEADD(hour,-4,timefield) In your query (assuming rest of query is fine): SELECT ItemId, MsgID, CONVERT(DATE,[Date]) [Date], CONVERT(VARCHAR(10),DATEADD(hour,-4,CAST([Date] AS TIME)),108) AS [Time], CASE WHEN MsgID = '1' THEN SUBSTRING(Parms,1,6) +' Was removed from:' WHEN MsgID = '2' THEN 'This Move List has been cleared of all its media' ELSE '' -- Optional Else END AS [RemovalPath], [OBJECT] [Move List:] FROM CTE WHERE [Date] >= CONVERT(DATE,DATEADD(DAY,-4,GETDATE()))

Categories : SQL



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.