PHP - Need Help With Warning: Date() [function.date]: In Blocked.php
I'm getting this Time Zone error.
Perhaps it's a compatibility issue with PHP 5.3. Looked all over for an answer without finding one. Here is the error message Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /blocked.php on line 41 12/02/12 Here is the code. Line 41 is near the bottom, the one with the d,m,y. Perhaps the echo date (d/m/y") needs to be changed. Appreciate any help! Code: [Select] <table border="3" width="16%" align="center" cellspacing="0" bgcolor="#FF6600" bordercolor="red" bordercolordark="red" bordercolorlight="red"> <tr> <td width="176"> <p align="center"><?php // shows IP Number on Page echo $ip; ?> </p> </td> </tr> </table> <p align="center"><?php // Show the user agent echo 'Your user agent is: <b>'.$_SERVER['HTTP_USER_AGENT'].'</b><br />';?></p> [b]<h1 align="center"><?php echo date("d/m/y");?></h1>[/b] </td> </tr> </table [,code] Similar TutorialsHey, 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 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? 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 (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 $date=date("Y-m-d H:i:s"); This is returning me the GMT time instead of EST. I get 15:26:08 as the time instead of 10:26:08. How can I get around this? How would you use the date function to display a birthday with an user's input? Hi all, I want to include the date and time in the web page to display when a user logged into the site. I found a code.I want to know how it could modify with relevant to our local time? <?php $today = date("d M Y h:i A"); echo $today ?> Thanks, Hello Again guys, I have varous dates stored in a database , these dates can look like this 2010-08-06 07/08/2010 07-08-2010 The problem is I dont know what format they are stored in.. What I need is a function which takes in 1 date at a time and returns it in a format I need it to be.. the format I need is 07/08/2010 thank you again for all you help I have been looking at thr date() but not been able to answer my qustion yet I am scraping Birthdays from a webpage that are in this format September 15, 1987 $age = 15; $page = source code of a html page; so far i have made this function How do i return the function as true if the date scaped makes the person over 15 and false if the person is younger? function checkForAge($page,$age) { preg_match('|Born on ([a-zA-Z]*\s[0-9]*,\s[0-9]*)\\\u003c\\\/span>|', $page, $match); if($match && count($match)>0) { echo "Match Found"; $dateOfBirth = str_replace(",","",$match[1]); // $dateOfBirth = date('d/m/Y', strtotime($dateOfBirth)); $dateOfBirth = strtotime($dateOfBirth); /* if("date of birth makes person over $age) { return true; } else { return false; } */ } Hi, I have the following code which lists all the dates since October 5th 2007 until yesterday's date, and displays it as a link. This part works fine. What I want to do is omit the weekends, so the first few lines would read like so: 05/10/2007 08/10/2007 09/10/2007 10/10/2007 11/10/2007 12/10/2007 15/10/2007 Does anyone know how I can modify this code, or have any other methods of doing this? Code: [Select] <?php function dates_between($start_date, $end_date = false) { if ( !$end_date ) { $end_date = date("Y-m-d"); } $start_date = is_int($start_date) ? $start_date : strtotime($start_date); $end_date = is_int($end_date) ? $end_date : strtotime($end_date); $end_date -= (60 * 60 * 24 + 1); $test_date = $start_date; $day_incrementer = 1; do { $test_date = $start_date + ($day_incrementer * 60 * 60 * 24); echo '<a href="http://markets.ft.com/RESEARCH/markets/DataArchiveFetchReport?Category=CU&Type=WORL&Date=' . date("m/d/Y", $test_date) . '">' . date("d/m/Y", $test_date) . "\n</a><br>"; } while ( $test_date < $end_date && ++$day_incrementer ); } dates_between("2007-10-04"); echo "\n\n"; ?> Thanks, Dave I am doing somthing complicated with dates and I think I am making it harder than I should. I need to subtract "x" number of months from the current date, then create 2 dates in that month that represent the first day, and last day of the month. Then make it in a format that SQL can read to get the SUMS I need between those dates. My last 2 strtotimes are wrong and are giving me the 1969 dates. Code: [Select] function commiss($nummonth){ $repnum = $_SESSION['REPID']; $date = date("Y-m-d", strtotime("-" . $nummonth . "")); $time2 = " 00:00:01"; $time = " 23:59:59"; $date1 =date("Y-m-d", strtotime(date('m').'/01/'.date('Y'))); $date2 =date("Y-m-d", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y'))))); $date1 = date("Y-m-d", strtotime("-" . $nummonth . "", $date1)); $date2 = date("Y-m-d", strtotime("-" . $nummonth . "", $date2)); $date1 = $date1 . $time2; $date2 = $date2 . $time; $string = "SELECT SUM(premium), SUM(repcom) FROM commission WHERE repnum = '$repnum' BETWEEN '$date1' AND '$date2'"; $sqltotal = mysql_query($string)or die (mysql_error()); $sqlprem = mysql_fetch_array('[SUM(premium)]'); $sqlcomm = mysql_fetch_array('[SUM(repcom)]'); echo "Premium: " . $sqlprem; echo "\n Rep Commission: " . $sqlprem; } i just want to display the values form database which i have saved before and just want to be displayed when specific time comes as i told above in e.g if i have stored some thing like value let say ( 10,20,30,40 and so on ) in database now i just want a php code to display it on site but on specific time only like this, i time = 10:00am display value = 10 when time = 10:30am display value = 20 when time = 11:00am display value = 30 and so own simple. 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 Hi, Currently I am making a module for joomla. every article has an publish date, if the article was published in 7 days ago, it will displayed as "article in last week", My idea is to use today's date - publish date, if the result is greater than 7 and smaller than 14, the article will be displayed as "article in last week. Any one know how to write this code? Here is what I have got, but not working. <?php $todays_date = date("Y-m-d"); $result = mysql_query("select * from jos_content where $test between $todays_date-14 and $todays_date-7"); while($row = mysql_fetch_array($result)) { echo "$todays_date - $row[title]"; } ?> Hi Guys.. How can I change a date on the fly ? Everything is UTC on my server. How can I change a date to something else on the fly? Ie: $timezone = "cet"; $datetime = "2011-09-04 19:53:00"; echo $datetime($timezone); So I can give it a datetime and have it echo the datetime as if it were in the other timezone? Thanks Graham 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, I am trying to convert a String date into numeric date using PHP function's, but haven't found such function. Had a look at date(), strtotime(), getdate(); e.g. Apr 1 2011 -> 04-01-2011 Could someone please shed some light on this? Regards, Abhishek |