PHP - Php Help To Converts Dates To Certain Numbers.
Im trying to auto download html pages from the net.
Their sports picks.. basically I am doing this through cron. So I dont need to touch it when its figured out. Ok .. ive looked at lots of days bettwen dates scripts.. but I need this below.. say December 10th is the last day.. and today its October 14th. now theres dark days every tuesday and wednesday.. the html links are link www.blablba.com/nhl/146.html basically 146 is todays number.. oct 14.. so it being friday.. we will have sat which will be... 147.html .. then sun 148.html then mon 149.html... skip tues skip thursday.. then friday should be 150.html all the way up to december 10th. Does anyone have a smart way to script this? I was either thinking date = the number or automatically letting each date figure out the page number every day. lol is this even make sence?? sorry if not. How about.. I need the days from today till december 10th to count how many days have passed.. excluding tuesdays and thursdays.. then I'll just make oct14th = 146 then todays number = current number from date + oct14th Similar TutorialsHi. I have this line of code: $b = '@'; I am trying to assign a text value to an XML node. $Data->nodeValue = '<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:'.$URN_UUID_ATTACHMENT.'" />' The resulting xml is: Code: [Select] <Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:1294192877" /></Data> is there a way to generate this instead: Code: [Select] <Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:1294192877" /></Data> Hi All, I need to subtract dates and display the number of days left. I have a 'Start' date and an 'End' date in DATETIME format in the DB. Not quite sure where to start. A simply start - end doesn't work . Start = 2011-11-01-00:00:00 End = 2011-11-30-23:59:59 Since it is now 2011-11-27, my output should equal 3. Any help is appreciated. Hi guys, I am trying to do a multidates events availability calender. The script below indicates todays date by highlighting an orange colour and also indicates the start and end date of the event highlighting grey colour on the two dates (The colour are link via css classes as shown). Code: [Select] //Today's date $todaysDate = date("d/m/Y"); $dateToCompare = $daystring . '/' . $monthstring . '/' . $year; echo "<td align='center' "; if($todaysDate == $dateToCompare){ echo "class='today'"; }else{ //Compare's the event dates $sqlcount = "select event_start,event_end from b_calender where event_start ='".$dateToCompare."' AND event_end='".$dateToCompare."'"; $noOfEvent = mysql_num_rows(mysql_query($sqlcount)); if($noOfEvent >= 1){ echo "class='event'"; } } It works ok i.e. if start date = 01/01/2012 and end date = 04/01/2012 both date will be highlighted with grey colour. However I want it to also highlight grey on the dates between the 1st and 4th to show that then anydates between the 1st and 4th are not available and this is when I'm stuck. Please guys I need help. Thanks Hi, I need to sort variables in groups of up to 15 and put it in an array. For example: $exstract['center_tabOpBody_0'] =5 $exstract['center_tabOpBody_1'] =6 $exstract['center_tabOpBody_2'] =8 $exstract['center_tabOpBody_3'] =1 Should yield: ARRAY( = center_tabOpBody_1,center_tabOpBody_2,center_tabOpBody_3 // <-----15 [1] = center_tabOpBody_0 //<----5 ) Is there some simple function do do the "efficiency" sort? Thanks, Vadim Hi, So I only want my users to be able to perform certain tasks each 12 hours. This is the code I use: Code: [Select] function canVote($ip, $vote_id, $updateTimer = true){ $time = date("Y-m-d H:i:s"); $this->CI->db->where('vote_id', $vote_id); $this->CI->db->where('user_ip', $ip); $this->CI->db->from('votes_voters'); $count = $this->CI->db->count_all_results(); /*$count = $this->CI->db ->where('vote_id =', $vote_id) ->where('user_ip =', $ip) ->from('votes_voters') -count_all_results();*/ $row = $this->CI->db ->where('vote_id =', $vote_id) ->where('user_ip =', $ip) ->get('votes_voters') ->row(); if($count == 0){ $data = array( 'vote_id' => $vote_id, 'user_ip' => $ip, 'last_vote' => $time ); $this->CI->db->insert('votes_voters', $data); return true; } else{ $last_vote = $row->last_vote; if($last_vote + strtotime("12 hours") < $time){ return false; } else{ if($updateTimer = true){ $data = array( 'last_vote' => $time, ); $this->CI->db->where('vote_id', $vote_id); $this->CI->db->where('user_ip', $ip); $this->CI->db->update('votes_voters', $data); } return true; } } } Apparently the failing bit is this: Code: [Select] if($last_vote + strtotime("12 hours") < $time){ return false; } I believe you can guess what I'm trying to do here, if variable 1 + 12 hours is smaller than variable 2, then return false. Any help is much appreciated. i want to created a case like the following need help with the syntax: Code: [Select] switch (true) { case($fromdate-$todate==17-04-2001-25-04-2011): echo $finalprice = $result; break; } Hey guys, What I'm trying to do is set 2 dates. Today's date and then a date 14 days from now. However, I want it to increase the month if by adding 14 days will bring me to the next month, same with the year. I have this, but it doesn't increment the month or year. $week = mktime(11, 59, 59, date("m"), date("d")+14, date("y")); $date = date("Y-m-d H:i:s", $week); Hey, I have just recently coded a forum and my topics are ordered by date. This means if there is a topic at 4pm and then there is another topic made at 4:01pm the topic which was posted at 4:01pm will be listed at the top. I know how to add timezones but there is bit of a problem, if person from the UK posts a topic and his/hers timezone is set to: date_default_timezone_set('Europe/London');() this means the time at which the topic was posted will be 20:36pm (Just a randome time example). However if someone posted a topic from america/los_angeles one hour before the one above his/her time will be 11:36 am. Even though this topic was posted one hour before the UK post. The UK topic will override it because it is 8:36pm. In fact, all UK topics will show up at the top and all the america/los_angeles topics will show bellow. How do I slove this problem? I just don't get it even tough I looked online. Please help, thanks. Hi guys, I am trying to create a program which manages campaigns. each campaign has a start date and and end date. a user has to enter data releated to the campaign everyday example start date: 10-1-2011 end date: 17-1-2011 now all this information is stored in 2 tables 1st table is "campaigns" this stores the campaign name, start date and end date and 2nd table is "campaign_data" this table stored the data for each campaign and also date of when that data was entered my question is, if the user did not enter data on 11-1-2011 how will I know this, keeping in mind the month diffrence which can accur if the length of the campign was 2 month long? table: campaigns fields: id | campaign_name | start_date | end_date table: campaign_data fields: id | campaign_id | date | page Thank you i have installed a calendar i want to extract the available id_item that are not id_state=1(booked) i want to query all the items that are not booked the dates: $fromdate=22-03-2011; $todate=25-03-2011; Code: [Select] this is bookings.php mysql_select_db($database_international, $international); $query_RsBookingIO = sprintf("SELECT * FROM `bookings` LEFT JOIN bookings_items ON bookings.id_item = bookings_items.id WHERE dateDIFF (2011-03-22, 2011-03-25) and bookings.id_state ='1' LIMIT 0 , 30 ", GetSQLValueString($colname_RsBookingIO, "int")); $RsBookingIO = mysql_query($query_RsBookingIO, $international) or die(mysql_error()); $row_RsBookingIO = mysql_fetch_assoc($RsBookingIO); <?php do { echo $row_RsBookingIO['the_date']; ?> <?php } while ($row_RsBookingIO = mysql_fetch_assoc($RsBookingIO)); ?> now when creating the searchfunction.php <?php $data = file_get_contents('http://localhost/bookings.php?fromdate=$fromdate and todate=$todate'); $fromdate = $_GET['fromdate']; $todate = $_GET['todate']; $dates = explode(' ',$data); var_dump($data); foreach($dates as $aDate) { echo $aDate; //$aDate = '\''.$aDate.'\''; if (!in_array($aDate, $dates)) { $available = true; } } return $available; ?> //tables CREATE TABLE `bookings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_item` int(20) NOT NULL DEFAULT '0', `the_date` date NOT NULL DEFAULT '0000-00-00', `id_state` int(11) NOT NULL DEFAULT '0', `id_booking` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `id_item` (`id_item`), KEY `id_state` (`id_state`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; -- -- Dumping data for table `bookings` -- INSERT INTO `bookings` VALUES(1, 2, '2011-03-22', 1, 0); INSERT INTO `bookings` VALUES(3, 2, '2011-03-23', 1, 0); INSERT INTO `bookings` VALUES(4, 2, '2011-03-24', 1, 0); INSERT INTO `bookings` VALUES(5, 2, '2011-03-25', 1, 0); INSERT INTO `bookings` VALUES(6, 2, '2011-03-26', 1, 0); INSERT INTO `bookings` VALUES(7, 3, '2011-03-23', 1, 0); INSERT INTO `bookings` VALUES(8, 3, '2011-03-24', 1, 0); INSERT INTO `bookings` VALUES(9, 3, '2011-03-25', 1, 0); INSERT INTO `bookings` VALUES(10, 3, '2011-03-26', 1, 0); INSERT INTO `bookings` VALUES(11, 3, '2011-03-27', 1, 0); CREATE TABLE `bookings_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_user` int(11) NOT NULL DEFAULT '1', `id_ref_external` int(11) NOT NULL COMMENT 'link to external db table', `desc_en` varchar(100) NOT NULL DEFAULT '', `desc_es` varchar(100) NOT NULL DEFAULT '', `list_order` int(11) NOT NULL DEFAULT '0', `state` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `id_user` (`id_user`), KEY `id_ref_external` (`id_ref_external`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Dumping data for table `bookings_items` -- INSERT INTO `bookings_items` VALUES(1, 1, 4600, 'Suite_A', 'Suite_A', 2, 1); INSERT INTO `bookings_items` VALUES(2, 1, 4601, 'Suite_B', 'Suite_B', 2, 1); Hi I'm trying to get this to work. I have known date in MySQL database entered as 2019-08-01 and I need to calculate from that date to current time. What I have is this code $date_ts = strtotime($row['date_ts']); //Timestamp $date_str = date("M-d-Y", $date_ts); //String in format MMM-DD-YYYY $TotalTime = floor((time() - $date_ts)/(60*60*24)) . ' days';//Total in days but my result showing as ==> 18367 days Could someone please help me get this to work so it shows the right number of days. thank you
how do I order two tables by date so that the most recent are first and the most unrecent last? like table 1 should be first then a table 2 then a table 1. does this make sense? so i have a basic html table and down the left column i have monday,tuesday,wednesday.... sunday. In the column 2nd from the left, i want to fill it with the current weeks dates, which is really based on the current date. So if today is Jul 29th Friday, then strtotime("last monday") would give me Jul 26th Monday... my issue is "last monday" wont work if today is monday because that will give me 19th of july... and since I technically dont know what day is today i'm not sure how to cleanly work around this without having to use some if statement... if today is monday do "last monday +7 days" or just do "now" etc... Thanks! There are two things I want done. 1. Grab the current date in TIMESTAMP form and increase by a certain number of days as assigned by $days() 2. Similar to the previous one, it will grab an already specified TIMESTAMP, and work from there All it echoes is 86400, which I assume is the number of seconds? Code: [Select] <?php $days = 1; echo strtotime("+$days days", strtotime($date)); ?> hey days im trying to get the differnce between the two dates but Code: [Select] $start_date = new DateTime($start_date); $todays_date = new DateTime("now"); $interval = $start_date->diff($todays_date); echo $interval->format('%R%a days'); but the error im getting is Fatal error: Call to undefined method DateTime::diff() i dont see what im doing wrong if someone could help please thank you Hi There, I am trying to create a table, and accross the top I would like the Week Commencing Dates of the last 5 weeks. So for example: <table> <tr><td>07/02</td><td>31/01</td><td>24/01</td><td>17/01</td><td>10/01</td></tr> </table> Can anyone help? Cheers Matt Hi, I have a created comment system, now what i am after is when the comment is posted the time is posted in hidden format. All is going fine but what i don't know, what should the time be posted as example date(H:m:s) or... the result i want is time in minutes first e.g. commented 2 mins ago and increasing to hours after that days. Could some one kindly guide me in the right directions. Hello. I wanted to make a table where the dates are listed going forward at least one year. So, at least 365 records, but each date should be unique and should start from today until one year from now. I tried to make a date column and make it a primary key.
However, an error comes up when I try to insert more than one record. This is for a calendar that I'm building so I need the dates listed one year in advance and it would be great if new dates could be added without my having to manually go in there and insert new records to stick to my 1 year in advance rule.
For that aspect I might have to create a php script where the date records are added every time a user logs in, to make sure they are up to date, but anyways what I don't understand is why I can't make a table with 1 year of date records in advance, where each row has a unique date starting from today.
|