PHP - How Can I Set Php Dates 10 Years Into The Future?
Hi everyone,
I'm writing a science fiction wordpress blog set 10 years into the future. I basically need all posts to display as if they are 10 years from now. Eg. posts needs to display as: February 7, 2021 instead of February 7, 2011 This will be for every post that I write. How can I automatically add 10 years to every post date? (And where would I put that code?) Currently, the wordpress php is calling the date with `<?php the_time(__('M j, Y')) ?>` I realise it's a bit of an odd request, but it's necessary for this particular project. I know it's possible - but I'm brand new to php and am not sure how. =) I hope someone out there can help. It would be very much appreciated. many thanks in advance Luke Similar TutorialsHi i have this drop down list current the year is 2010 and downwards but i want to change the list to 2010 upwards u can notice on the 50-- so shows current year minus so current is 2010 to 61 how can i change 2010 to 2030 or sunfin?? echo '<select name="year_of_birth">',"\n"; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { if($i == $thisYear) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; I want to set a never expire date, so I figured I would set the date 99 years into the future. No dice. After trial and error, it appears you can only make it 25 years into futu date("Y-m-d",strtotime("+25 years")); I wonder if it is the absolute date, or the number 25. If it is the maximum date (i.e. nothing after 2035) then I will have a problem with this code next year! 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.
Evening All, How would I go about selecting a future date based on a date? What I want to achieve is to take todays date, add ten days to it and then store it as the month end following that date. For example 19th Nov + 10days = 29th November = 31st Dec Many thanks for any pointers! This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321426.0 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 Guys, In a form within PHP coding i can get the the next 10 years with the following code: Code: (php) [Select] <?php $date_future = date("Y", strtotime('+10 year')); $date_year = date("Y"); for($i=$date_year;$i<$date_future;$i++){ if($date_year == $i){ echo "<option value=\"$i\" selected=\"selected\">$i</option> \n"; } else { echo "<option value=\"$i\">$i</option> \n"; } } ?> I have tried to mess about with the same code and try and get it to work for the last 10 years without any luck. He's what i did: Code: (php) [Select] <?php $date_past = date("Y", strtotime('-10 year')); $date_year = date("Y"); for($i=$date_year;$i>$date_past;$i++){ if($date_year == $i){ echo "<option value=\"$i\" selected=\"selected\">$i</option> \n"; } else { echo "<option value=\"$i\">$i</option> \n"; } } ?> I would appreciate any help with this. I can determine 3 years from today, but How do determineo 3 years from march 1st? So I want to echo out "3/1/2013"? Thanks! Ok so here is my code. Ignore the $_POST['dobm']. That is part of the whole script. All I want to know is how to set the list from 1998 to 1911 in descending order. I already tried making $i = 1998 and make $i - 1 til $i >= 1911. It seems to go in an infinite loop when I do that. Code: [Select] <?php for($i = 1911; $i <= 1998; $i++) { if ($_POST['dobm'] == $i) { echo '<option selected="selected" value="'.$i.'">'.date('Y', mktime(0,0,0,0,0,$i+1)).'</option>\n'; } else { echo '<option value="'.$i.'">'.date('Y', mktime(0,0,0,0,0,$i+1)).'</option>\n'; } } ?> I am searching the database for items that are plaques. There are different years of plaques. I find all the plaques sorted by year. My display puts them in rows of 4 max. What I want is to display them by year with a different year on a different line. Right now there are 4 (1963), 3 (1965), 1 (1978) all bunched together. 1963, 1963, 1963, 1963, 1965, 1965, 1965, 1978 What I want is: 1963, 1963, 1963, 1963, 1965, 1965, 1965, 1978, Any help would greatly be appreciated. <?php include 'config0.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("$dbname")or die("cannot select DB"); $result = mysql_query("SELECT * FROM table1 WHERE plaques LIKE '%$search%' ORDER BY year") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 4; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $tn; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> How can i group the data by year to build the graph I need the data to be like so 2012 0 - total customers 0 - total customers 0 - total customers 0 - total customers 0 - total customers 9 - total customers 5 - total customers 3 - total customers 5 - total customers however i only have this data Code: [Select] total_customers month year 1 Aug 2011 9 Oct 2011 8 Nov 2011 4 Dec 2011 4 Jan 2012 so i need to make it show 0 for the months i dont have data for Code: [Select] <div id="dash_chart" class="portlet x9"> <div class="portlet-header"> <h4>Customer Growth</h4> <ul class="portlet-tab-nav"> <li class="portlet-tab-nav-active"><a href="#tab1" rel="tooltip" title="Customers">Customers </a></li> <li class=""><a href="#tab2" rel="tooltip" title="Sales over last 48 hours.">Sales </a></li> </ul> </div> <!-- .portlet-header --> <div class="portlet-content"> <div id="tab1" class="portlet-tab-content portlet-tab-content-active"> <?php echo '<table class="stats" title="area" width="100%" cellpadding="0" cellspacing="0"> <caption>Customer Base Growth</caption> <thead> <tr>'; $monthNames = Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); $i = 0; foreach ($monthNames as $month){ echo '<th>'.$month.'</th>'."\n"; } echo '</tr> </thead>'; $q = "SELECT count(cus_id) as total_customers, DATE_FORMAT(sign_date, '%b') as month, YEAR(sign_date) as year FROM customers GROUP BY YEAR(sign_date), MONTH(sign_date) ORDER BY sign_date ASC"; $r = @mysqli_query ($dbc, $q); $data = array(); if (mysqli_affected_rows($dbc) >= 1) { echo '<tbody> <tr> <th>2011</th>'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { } } echo '</tr>'; ?> <tr> <th>2012</th> <td>3</td> <td>4</td> <td>2</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>3</td> <td>5</td> <td>3</td> <td>9</td> </tr> </tbody> </table> if(!is_array($e)) { $fulldisp = 1; $e = array('title' => 'No Entries Yet', 'entry' => '<a href="../admin.php">Post an entry!</a>' ); } } // Add the $fulldisp flag to the end of the array array_push($e, $fulldisp); return $e; } can someone please tell me why I'm getting this notice ? Notice: Undefined variable: e in /var/www/blog/inc/functions.inc.php on line 40 Hello All, I have a News database in which articles are entered in. Right now all the stories are being display in one big page with every story on it. What I would like to do is to create an "archive" in which it automatically organizes the stories by their date. For example. 2011 February January 2010 December November October September etc... etc... I have a datetime field for the database, and I know how to do this all manually, but I can't figure out how to make it automatically add a month each month. It would be too much maintanence to have to update this every month. I also don't know what this would be called, so I don't even know what to search for. I've tried blog and news, but doesn't seem to be what I want. Any help would be appreciated! I have this form:
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=318996.0 I write with Object orientated programming style in all languages where possible. Languages i am experienced with: PHP4/PHP5 Mysql/Mysqli/PDO CSS/CSS3 Html/html5 Javascript (i prefer not to use libraries but i can use jquery just fine). C++ Console C# Silverlight C# windows phone 8.1 Graphic design: Photoshop cs6 fireworks cs6 (i prefer not to use fireworks though) Familiar operating systems: Linux Windows Extra info: I work with Apache and have experience maintaining the server. I like to work over SSH (secure shell). I program in Notepad or command prompt only!. I do not use frameworks or special software! Again i am looking for IMMEDIATE work. Thanks Sometimes i over think things and need to be told EXACTLY what it is you want VERY SLOWLY. I have started learning OOP, by following a few tutorials, My problem with most tutorial is they show you how, but don't tell you the what and the why. It's all good an well seeing what to do, but if you have no idea why it's being done, you don't learn much. I started a tutorial on Udemy but am not actually gaining a lot from it. I want to alter the code so that it will do it the way I want it to. I am not wanting you to write the code for me, if you do please explain it so that I can understand the logic, preferably show me where to make changes and point me at the php tutorial that can solve my problem. I have been trying to solve this for a couple of weeks now, I tried a few things but none worked.
The full followLinks function function followLinks($url) { global $alreadyCrawled; global $crawling; $host = parse_url($url)["host"]; $parser = new DomDocumentParser($url); $linkList = $parser->getLinks(); foreach($linkList as $link) { $href = $link->getAttribute("href"); if((substr($href, 0, 3) !== "../") AND (strpos($href, $host) === false)) { continue; } else if(strpos($href, "#") !== false) { continue; } else if(substr($href, 0, 11) == "javascript:") { continue; } // I need to change this below somehow, the two arrays are identical, // What I want to do is move $href(crawled) to $alreadyCrawled and remove it from $crawling // I also want to check if the current $href (crawling) is in $alreadyCrawled and if it is skip crawling and move on to the next one. //In essence I want to prevent the crawler from crawling anything already crawled in order to speed up the crawler. $href = createLink($href, $url); if(!in_array($href, $alreadyCrawled)) { $alreadyCrawled[] = $href; $crawling[] = $href; } else { continue;} echo $href . "<br>"; } array_shift($crawling); foreach($crawling as $site) { followLinks($site); } } $startUrl = "https://imagimedia.co.za"; followLinks($startUrl); ?>
Result.
https://imagimedia.co.za/../seo/ https://imagimedia.co.za/../pages/marketing.html https://imagimedia.co.za/../pages/web-design.html http://imagimedia.co.za/ https://imagimedia.co.za/../website-cost-quote.php https://imagimedia.co.za/../blogs/history.html https://imagimedia.co.za/../blogs/payment.html https://imagimedia.co.za/../blogs/copy.html https://imagimedia.co.za/../blogs/cycle.html https://imagimedia.co.za/../blogs/information.html https://imagimedia.co.za/../blogs/privacy.html https://imagimedia.co.za/../blogs/terms.html https://imagimedia.co.za/../blogs/content-is-king.html https://imagimedia.co.za/../blogs/pretoria-north-web-design.html https://imagimedia.co.za/../blogs/annlin-web-design.html https://imagimedia.co.za/../blogs/ http://imagimedia.co.za http://imagimedia.co.za/../seo/ http://imagimedia.co.za/../pages/marketing.html http://imagimedia.co.za/../pages/web-design.html http://imagimedia.co.za/../website-cost-quote.php http://imagimedia.co.za/../blogs/history.html http://imagimedia.co.za/../blogs/payment.html http://imagimedia.co.za/../blogs/copy.html http://imagimedia.co.za/../blogs/cycle.html http://imagimedia.co.za/../blogs/information.html http://imagimedia.co.za/../blogs/privacy.html http://imagimedia.co.za/../blogs/terms.html http://imagimedia.co.za/../blogs/content-is-king.html http://imagimedia.co.za/../blogs/pretoria-north-web-design.html http://imagimedia.co.za/../blogs/annlin-web-design.html http://imagimedia.co.za/../blogs/ I know I am also going to have to exclude duplicates created by the http and https pages. But that is not my main issue. What are your feelings regarding Linux desktop distros, and their ability to break through to mainstream usage? I started using Ubuntu about 6 or 7 years ago, and have fooled around with some other distros, but at least for me Ubuntu always seemed the best. I've got my 65 year old mom using it, and my 11 year old son playing with Kubuntu (and learning python!). I don't really consider us normal though; normal being almost too dumb to do more than check email and get on the internet.
I've managed to fully switch over to Ubuntu on all of my computers, with the exception of running Windows in a VM for Photoshop and Illustrator. Since I don't use those programs every day, there are a lot of days where I don't see Windows. I never really had a problem with Windows, except for Windows 3.1 was kind of a drag. Getting on the internet on a 56K modem on Windows 95 wasn't any fun either, but that wasn't Windows' fault. I never had the crashes and bad experiences people like to claim makes Windows suck. My main reason for abandoning Windows is just to be more involved with Linux, and hopefully reach Linux guru status someday.
I really never liked Macs. I bought one 3 or 4 years ago, and it just felt like I was paying a lot of money for a glorified (and over-hyped) linux distro. I really never liked the feel of the Finder. At the time there was no awesome text editor, and I bought a couple just to test out what I could find. Unlike Windows and Linux, it seemed like nothing is free in the Mac world. I eventually gave the Mac away. We couldn't be friends.
I'd really like to see Linux become the dominant OS. It's exciting to see how far Ubuntu has come in the years that I've used it, and I evangelize for Linux/Ubuntu quite a bit. Even still, it can sometimes seem that I am a stranger in a strange world. Do you think we can count on Linux being a bigger part of mainstream computing? One of the problems I see is that there are so many distros that a person investigating Linux may be a little overwhelmed. What do you think is keeping the masses from using Linux desktops?
Hi, I am using this function to output a list of dates for every friday over the next 12months. This is working fine. Code: [Select] [php] //function function nextWeeksDay($date_begin,$nbrweek) { $nextweek=array(); for($i = 1; $i <= $nbrweek; $i++) { // 52 week in one year of course $nextweek[$i]=date('Y-m-d', strtotime('+'.$i.' week',$date_begin)); } return $nextweek; } /// end function /// example of a select date // var $date_begin=strtotime('this Friday'); $nbrweek=52; // call function $result=nextWeeksDay($date_begin,$nbrweek); // Insert //$date1=date('Y-m-d', $date_begin); for($i = 1; $i <= $nbrweek; $i++) { //$date=$result[$i]; echo $result[$i]."<br/>"; } [/php] My problem is that when I alter the code to try and get the date for every second Friday for the next year the script freezes. Code: [Select] [php] //function function nextWeeksDay($date_begin,$nbrweek) { $nextweek=array(); for($i = 2; $i <= $nbrweek; $i+2) { // 52 week in one year of course $nextweek[$i]=date('Y-m-d', strtotime('+'.$i.' week',$date_begin)); } return $nextweek; } /// end function /// example of a select date // var $date_begin=strtotime('this Friday'); $nbrweek=52; // call function $result=nextWeeksDay($date_begin,$nbrweek); // Insert //$date1=date('Y-m-d', $date_begin); for($i = 2; $i <= $nbrweek; $i+2) { //$date=$result[$i]; echo $result[$i]."<br/>"; } [/php] I really don't understand why?? Does anyone know why? Thanks |