PHP - Strange Issue With Dates
Can anyone help?
the date is pulling through without a value shown in bold below. `Timesheet_start_date` >= '2011-02-10 00:00:00' AND `Timesheet_end_date` <= '1970-01-01 00:00:00' ORDER BY id DESC here is my code: Code: [Select] $smalldate = $_POST['small']; $largedate = $_POST['large']; $types[] = (isset($_POST['small']) && strlen(trim($_POST['small'])) > 0) ? "`Timesheet_start_date` >= '".date('Y-m-d',strtotime($smalldate))." 00:00:00'" : ''; $types[] = (isset($_POST['large']) && strlen(trim($_POST['large'])) > 0) ? "`Timesheet_end_date` <= '".date('Y-m-d',strtotime($largedate))." 00:00:00'" : ''; i've echo the $largedate and there is a value in there? Similar TutorialsGood morning, I have a wordpress theme I am using and I thought all was working well. I've noticed that when I'm not logged into admin, it doesn't show any pages for me, only white pages. When I switched back to the default TwentyTwelve theme, it worked all ok for me. Has anyone had this problem before? Thanks for your time. Kind regards, L2c Hello I am facing a rare issue while uploading videos, now the test is on .flv 7 mega and .wmv 5 mega Not Only the file is not getting uploaded, I cannot even see the tmp_name and ize is 0 I have included: ini_set("post_max_size", "10M"); ini_set("upload_max_filesize", "10M"); and <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> This is all locally on the localhost, nothing allows for uploading the video Many Thanks So I have a simple query that adds a text record into a MySQL database table. It works great with exception of one thing. I noticed that if I have "&" symbol in my paragraph, the text after that symbol won't be inserted into the table. The text before that symbol will insert fine. It seems to be doing that only with & symbol; other symbols insert and show up fine. can anyone tell me why this is happening? I have been using arrays and classes for awhile. However, I am having an issue I have never had before. I am using Codeignitor. I am getting a set of results. These results are returned as a class. Then I am looking through them and displaying them in a complex set. I am having to get some additional data and add it to it. Is there a way to add an array into a class as a class? For example. I have a class: Class->0->allthedata Class->1->allthedata Class->2->allthedata Class->3->allthedata Then I get my array Array[0][allthedata] Array[1][allthedata] Array[2][allthedata] I want to add that to the class Class->4->allthedata Class->5->allthedata Class->6->allthedata I am not sure if that makes sense. Is this possible? To just add some records at te end of the class with autonumbering. 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 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, 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. 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 Hello Everyone, I seem to be going no place fast... In a PHP file, I should be taking a date from a jquery datpicker, and get it to a format that mysql will read in the yy-mm-dd format with... if(isset($_POST['choice'])) $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); Can't seem to get a single inline(embeded) jquery Datepicker date to post right to the PHP and mysql correctly to return data from the table.. My reading has me to understand it should be right, but it is not. Now the datepicker select does have several POST events to PHP that trigger from the single select... data being requsted in PHP by the day, month, and year as well as PHP to use the date to create a highcharts graph in the PHP file to select data for hours of a day, days of a month, and months of a year. The Table is very simple... date, time, power Here is the PHP for dayPower.php that will just collect the sum data for the selected day in the datepicker... <? if(isset($_POST['choice'])) $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); $con = mysql_connect("localhost","root","mackie1604"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = 'SELECT sum(power) AS power ' .'FROM feed ' .'WHERE date = $choice'; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); echo $row['power']; ?> Here is the javascript that sends the date and how it post the PHP file. Code: [Select] $(document).ready(function () { $('#datepicker').datepicker({onSelect: function(dateText,inst) { var myDate = $(this).datepicker('getDate'); $('#apDiv1').html($.datepicker.formatDate('DD, d', myDate)); $('#apDiv5').html($.datepicker.formatDate('MM', myDate)); $('#apDiv7').html($.datepicker.formatDate('yy', myDate)); $.post('dayPower.php', {choice: inst.val()}, function(data) { $('#apDiv2').html(data).show(); }); $.post('dayGraph.php', {choice: inst.val()}, function(data) { $('#apDiv4').html().show(); }); $.post('monthPower.php', {choice: inst.val()}, function(data) { $('#apDiv6').html(data).show(); }); $.post('monthGraph', {choice: inst.val()}, function(data) { $('#apDiv9').html().show(); }); $.post('yearPower.php', {choice: inst.val()}, function(data) { $('#apDiv8').html(data).show(); }); $.post('yearGraph', {choice: inst.val()}, function(data) { $('#apDiv10').html().show(); }); }}); }); What am I doing wrong Alan Code: [Select] <?php $date = date('Y-m-d'); $strtime = strtotime('today +14 days'); $strtime = date('Y-m-d', $strtime); if ($distributor != 1) { $select = "SELECT deal_data.headline AS headline FROM deal_data WHERE str_to_date(deal_data.end_date,'%Y/%m/%d') BETWEEN str_to_date('" . $date . "', '%Y/%m/%d') and str_to_date('" . $strtime . "', '%Y/%m/%d')"; }else { $select = "SELECT deal_data.headline AS headline FROM deal_data WHERE str_to_date(deal_data.end_date,'%d.%m.%Y') BETWEEN '" . $date . "' and '" . $strtime . "'"; } ?> The dates are formatted in the database as Varchar (I don't do that anymore, this is an old project) and are formatted as: "09/12/2010". Anything wrong with the above code that would make it not work and return queries? I was just wondering if anyone can reccomend the best way to get dates from a database and turn them into dates you can display. For example if you have a date stored such as 23/08/10, is there an easy way to turn this into 23rd August 2010? Thanks for any help. I'm trying to make a script to check a files date time and if its under so many seconds long the page will refresh. here is what I've got. I've been testing the output of the date() functions but when i do the math all i get is a 0. where did i go wrong? is it just i can't do math with dates? Thanks in advanced. Code: [Select] <html><head> <meta http-Equiv="Cache-Control" Content="no-cache"> <meta http-Equiv="Pragma" Content="no-cache"> <meta http-Equiv="Expires" Content="0"> <? $proFile = "profilePics/profile.jpg"; //if ( date ("m d Y H:i:s.") - date ("m d Y H:i:s.", filemtime($proFile)) <= 00 00 0000 00:00:04 ){ //this is where the magic should happen. //echo "<meta http-equiv="refresh" content='4'>"; } ?> </head> <? echo date ("m d Y H:i:s."); echo "<br>"; echo date ("m d Y H:i:s.", filemtime($proFile)); echo "<br>"; echo date ("m d Y H:i:s.") - date ("m d Y H:i:s.", filemtime($proFile)); //only outputs 0 ?> 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! 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
Hi, I'm trying to get the date, using this code <?php include('config.php'); $today = date('Y-m-d 00:00:00'); $nineyesterday = date('Y-m-d H:i:s', mktime(date("H") - (date("H") + 6), date("i") - date("i"), date("s") - date("s"), date("m") , date("d"), date("Y"))); $now = date('Y-m-d H:i:s'); $nineam = date('Y-m-d 9:00:00'); $ninepm = date('Y-m-d 18:00:00'); if ((strtotime($now) >= strtotime($today)) && (strtotime($now) <= strtotime($nineam))) { //count the answers by yes or no $q = "SELECT opt, count(opt) FROM plus_poll_ans WHERE date<='".$nineyesterday."' AND date>='".$nineam."' GROUP BY opt desc "; } elseif ((strtotime($now) >= strtotime($nineam)) && (strtotime($now) <= strtotime($ninepm))) { //count the answers by yes or no $q = "SELECT opt, count(opt) FROM plus_poll_ans WHERE date<'".$nineam."' AND date>='".$ninepm."' GROUP BY opt desc "; } $q = mysql_query($q) or die(mysql_error()); //separate the results while($row = mysql_fetch_array($q)) { $total_opt[] = $row['count(opt)']; } mysql_freeresult($q); $yes = intval($total_opt[0]); $no = intval($total_opt[1]); $total = $yes + $no; echo $total."<br/>"; echo $yes."<br/>"; echo $no."<br/>"; ?> but it didn't work, why isn't it working? Thanks |