PHP - Date Issue 01/01/2012 (not > Then 12/31/2011)
Problem: My query is set to get rows with date after x, as of today (January 1st, 2012) my query doesn't recognize 01/01/2012 as greater than day 12/31/2011.
Webpage: http://www.onlinegamekey. com/ MTGT-Auction.php Execution Code: Code: [Select] <?php ///Setting The Date & Query Range $today = date("m/d/Y"); $minusday = mktime(0,0,0,date("m"),date("d")-14,date("Y")); $queryday = date("m/d/Y",$minusday); ///Getting The Data $quer2=mysql_query("SELECT * FROM auctions WHERE Card_Name ='$cards' AND Day >='$queryday' ORDER BY Price_Per") or die; ?> Additional Notes: My database stores the date in this format mm/dd/yyyy in column `Day` stored as a VARCHAR. Testing on the site: Search for Air Elemental this card is new today (Auction ID)543716 (Card Name)Air Elemental (Cards Per Auction)1 (Seller)Edwitdahead (Auction Price)7 (Price Per)7.00 (Date)01/01/2012 I would like to avoid changing the database format if possible, and I assume this is likely a common issue so any help pointers or links you can provide to help me fix this is Greatly Appreciated. Thank you Similar TutorialsI have a php page where i need to list all item in a particular month.But the format for date stored is MMMM DD,yyyy that January 22, 2011. How do i extract the month name only from the above format Before reading, just know I am NOT a PHP programmer and have no experience with PHP. I am just trying to install a premade php based website.
My questions is: How do I make .php pages connect to my database?
I know the question is very broad and probably doesn't really make sense but I've been having errors trying to install/configure a php website. The php website has a config which I have filled out correctly and seems to work on my PC via localhost using XAMPP fine but it doesn't work on my Windows Server 2012 Apache machine whenever the .php configuration tries to alter or conenct to the MySQL database it displays errors like this:
Fatal error: Call to undefined function mysql_connect() in C:\Apache24\htdocs\includes\classes.php on line 378
That's just an example of one predefined PHP website errors that I've received they are all very similar. What I think is happening is the PHP code is trying to connect to the database but there's some sort of configuration variable on Apache that I have not correctly filled out. I have tried this twice with two different CMS and searched google far and wide to find an answer to my problem. I hope the answer is something simple. If you need anything because you think you know what is happening then I will provide any information needed to fix this problem.
Thank you.
Code: [Select] function timeAgo($tm,$rcs = 1) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array('second','minute','hour','day','week','month','year','decade'); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]); if(($rcs > 0)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= $this->timeAgo($_tm, --$rcs); return $x; } This is my function I use it alot My code: Code: [Select] $endtime = $std->timeAgo($lotto['start_time']+3600);$lotto['start_time'] = 1327482941 +3600 is 1 Hour correct? But this displays: Code: [Select] Next Drawing in: -3219 seconds each refresh it goes down 3218/etc which is GOOD! But why is it using the minus sign and not going through the function properly? Simplest of codes and simplest of errors. Darned if i can find it tho. I simply need to select the Max of Dates in a table. This is my code. But I cannot get it to work. Code: [Select] $sqlb = "SELECT MAX(QD) FROM `Qts` WHERE `OCID` = '$ocid' " ; //QD is the date column in YYYY-MM-DD format; $resultb = mysql_query($sqlb); $num_rows = mysql_num_rows($resultb); for($i = 0; $i < $num_rows; $i++) { $rowb = mysql_fetch_array($resultb); $qd = $rowb["QD"]; echo $qd; // should echo out the most recent date if say there were 2 entries of 2011-07-19 and 2011-08-26, then the latter should be output. } This doesnt happen. In fact the query doesnt run at all? What am I missing ? Thanks in advance for guidance ! Swati when trying to get the date
var visitors_time = new Date();i'll being back a result like Mon Oct 27 2014 20:54:55 GMT+0000 (GMT Standard Time)my issue is, is there a way of getting the end part with the brackets to not show up? ie. format the date?...ive googled but doesnt seem no simple solution like php to actually format the date to the way you'd like it thank you guys I'm having a weird issue going on, I'm wondering if it has to do with my php.ini or server setup, anyway here is the code with the odly outcomes: Code: [Select] echo date('Y/m/d H:i:s', 2145000000); // 2037/12/21 01:20:00 echo date('Y/m/d H:i:s', 2149000000); // 1901/12/31 01:58:24 echo date('Y/m/d H:i:s', 2150000000); // 1902/01/11 15:45:04 It seems after year 2037 it goes down to 1900+... Why would this happen? I've tried on 2 godaddy servers and local host and all same result Hi, Sorry, me again! Ok, so i've got my url: http://www.mydomain.com/?ec3_after=2010-08-01&ec3_before=2010-08-07 I've then got the following code to get the values: $afterDateParts = split("-", $_GET['ec3_after']); $after = $afterDateParts[2] . " " . $afterDateParts[1] . " " . $afterDateParts[0]; echo $after; which returns: 01 08 2010 (correct for this demo) I've then got this to convert the above into a nicer format: $convertMe = strtotime($after); echo date('d-M-Y', $convertMe); But it always returns: 01 Jan 1970 For the love of god, I cannot work out why. Is it really not that simple? Please someone put me out my misery. I'm loosing hair by the minute! Lol TIA I want to have a couple of different formats from mktime(), which the value could be: 1292183335. I would like to have some of the formats like: Tuesday at 12:00am, Wednesday, January 12, 2011 at 12:00am Also taking different timezones in consideration. I'm not sure what to use for that. Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack Hey Guys! I have the following doubt. When echoing from Server like this: Code: [Select] echo "time=" . time(); I get the time in the following raw format: 1299272294 I would really like to echo it with this format: Tue Mar 1 23:50:00 GMT-0300 2011 Is there a way I could do that? Really looking forward for some help on this one, Thanks a lot in advance! Cheers! Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. Alright, I have a Datetime field in my database which I'm trying to store information in. Here is my code to get my Datetime, however it's returning to me the wrong date. It's returning: 1969-12-31 19:00:00 $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); $phpdate = strtotime( $mysqldate ); echo $mysqldate; Is there something wrong with it? (continuing from topic title) So if I set a date of July 7 2011 into my script, hard coded in, I would like the current date to be checked against the hard coded date, and return true if the current date is within a week leading up to the hard coded date. How could I go about doing this easily? I've been researching dates in php but I can't seem to work out the best way to achieve what I'm after. Cheers Denno Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days. <?php $expired_date = get_post_meta( $post->ID, '_job_expires', true ); $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true ); if(empty($hide_expiration )) { if(!empty($expired_date)) { ?> <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span> <?php $datetime1 = new DateTime($expired_date); $datetime2 = date('d'); $interval = $datetime1->diff($datetime2); echo $interval->d; ?> <?php } } ?> Can anyone help me with what I have wrong? Many thanks Hi there, I have a string '12/04/1990', that's in the format dd/mm/yyyy. I'm attempting to convert that string to a Date, and then insert that date into a MySQL DATE field. The problem is, every time I try to do so, I keep getting values like this in the database: 1970-01-01. Any ideas? Much appreciated. Hi guys, I'm putting together a small event system where I want the user to add his own date and time into a textfield (I'll probably make this a series of drop-downs/a date picker later). This is then stored as a timestamp - "0000-00-00 00:00:00" which displays fine until I try to echo it out as a UK date in this format - jS F Y, which just gives today's date but not the inputted date. Here's the code I have right now: Code: [Select] $result = mysql_query("SELECT * FROM stuff.events ORDER BY eventdate ASC"); echo "<br />"; echo mysql_result($result, $i, 'eventvenue'); echo ", "; $dt = new DateTime($eventdate); echo $dt->format("jS F Y"); In my mysql table eventdate is set up as follows: field - eventdate type - timestamp length/values - blank default - current_timestamp collation - blank attributes - on update CURRENT_TIMESTAMP null - blank auto_increment - blank Any help as to why this could be happening would be much appreciated, thanks. i have a table that shows payments made but want to the payments only showing from a set date(06/12/14) and before this date i dont want to show
this is my sql that doesnt seem to work and is showing dates before the specified date.
.
"SELECT * FROM payments2014, signup2014, editprop2014 WHERE signup2014.userid = payments2014.payment_userid AND editprop2014.prop_id = signup2014.prop_id AND signup2014.userid !='page1' AND signup2014.userid !='page6' AND signup2014.userid !='page4' AND payments2014.payment_transaction_status !='none' AND payments2014.payment_transaction_status !='CANCELLEDa' AND payments2014.payment_type !='deposit' AND payments2014.payment_paid_timestamp NOT LIKE '%2012%' AND payments2014.payment_paid_timestamp NOT LIKE '%2011%' AND payments2014.payment_paid_timestamp >= '06/12/14' ORDER BY payments2014.payment_id DESC"i have some other parts in the statment but this one that should be filtering is host_payments2014.payment_paid_timestamp >= '06/12/14'thanks in advance |