PHP - Moved: Jquery Date Time Picker In Php
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=316616.0 Similar TutorialsHi, Im having some troubles with a date picker on a form. It enters the date into the date field like this : 21 Sep 2011 I want to be able to insert it into a date field in the mysql database but it just enters it as 0000-00-00 Any ideas ? Many thanks, Scott. Hi is it possible to make the Icon for my input activate the date picker (I'm using Materialize for my class) A lot of users seem to instinctively try to click the icon rather than the input field on mobile devices <div class="input-field col s12 m8 l7 xl7"> <i class="material-icons prefix">calendar_today</i> <input type="text" name="r_date" class="datepicker"> <label for="r_date"></label> </div> <script> $(document).ready(function(){ $('.sidenav').sidenav(); $('select').formSelect(); $('.datepicker').datepicker({ format:'yyyy-mm-dd' }); $(".dropdown-trigger").dropdown(); }); </script>
Hey guys, How would I go about subtracting Today from a previous day to find the difference? For example, I want to subtract TODAY from a previous date in my database, to determine if the difference is greater than 1 day. Any ideas? I tried doing the subraction in TIMESTAMPS, but when I convert the date back to Y-m-d H:i:s, I got some weird year and time. PHP date and time function is not showing correct time on my local system I have the following php code date_default_timezone_set("Africa/Lagos"); $date = date('d-m-y h:i:s'); echo "Server Time ".$date ."<br>"; echo "The time is " . date("h:i:sa")."<br>"; $current_datetime = date("Y-m-d") . ' ' . date("H:i:s", STRTOTIME(date('h:i:sa'))); echo "Current time1: ".$current_datetime . "<br>";
Output
Server Time 21-05-21 09:55:39
Expected Output
Server Time 21-05-21 10:55:39
Any help would be appreciated. Edited May 21 by Ponel I am having a problem with PHP displaying the correct date and time. It updates as it should, but is fast by 4min and is always displaying a date in 2004. I ran a basic php script to make sure the application im using itself is not wrong. go to lunenburgledger.com/time.php Anybody had any ideas on where to check? The system time on the Windows Server 2003 is correct. The only thing I can think of is that it was converted to a virtual machine on vmware esxi, but the system time stayed right. Any ideas? Thanks! OK So I've got a datepicker that sends a date in d/m/y format. My DB stores the data in Unix Timestamp Which I can convert the date to with strtotime however this does the exact date & time. All I want is the actual day. I've spent hours trying to convert this with just the day with mixed results... Thanks. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=316461.0 Hi, I have two timepickers start time and end time.When I select start time,the end time should have all the times disabled before start time.I am having Add button.When add button is clicked,again two timepickers are added.In these two,I can't able to set mintime of end timepicker from start time.Here is the code <div id='adddiv'> <input type="hidden" name="count" id="count"> <p>From:<input type="text" style="width: 70px;" id="timepicker1" name="visiting_time_start"/> To:<input type="text" style="width: 70px;" id="timepicker2" name="visiting_time_end"/> <a href='#' id='sadd'><img src="<?php echo base_url();?>template/images/plus_button.png" alt="Add"></a> </p></div> $(document).ready(function() { var addDiv = $('#adddiv'); var i = $('#adddiv p').size() + 1; var j=0;var k=i-1; $('#sadd').unbind("click").on('click', function() { var aid="timepickera"+k; var bid="timepickerb"+k; $('<p>From:<input type="text" id='+aid+' style="width: 70px;" name="visiting_time_start' + i +'" value="" />To:<input type="text" id='+bid+' style="width: 70px;" name="visiting_time_end' + i +'" value="" /><a href="#" id="srem"> <img src="<?php echo base_url();?>template/images/remove.jpg" height=16 width=16 alt="Remove"></a> </p>').appendTo(addDiv); $('#timepickera'+k).timepicker({ showLeadingZero: false, onSelect: function( time, endTimePickerInst ) { t1=time; $("#timepickerb"+k).timepicker('option', { minTime: { hour: endTimePickerInst.hours, minute: endTimePickerInst.minutes } }); }, minTime: { hour: 10, minute: 00 } }); $('#timepickerb'+k).timepicker({ showLeadingZero: false, }); i++;j++;k++; $('#count').val(j); return false; }); $(document).on('click', '#srem' , function(){ if( i > 2 ) { $(this).parents('p').remove(); i--;j--;k--; $('#count').val(j); } return false; }); $('#timepicker1').timepicker({ showLeadingZero: false, onSelect: tpStartSelect, minTime: { hour: 10, minute: 00 } }); $('#timepicker2').timepicker({ showLeadingZero: false, onSelect: tpEndSelect, }); }); // when start time change, update minimum for end timepicker function tpStartSelect( time, endTimePickerInst ) { $('#timepicker2').timepicker('option', { minTime: { hour: endTimePickerInst.hours, minute: endTimePickerInst.minutes } }); } // when end time change, update maximum for start timepicker function tpEndSelect( time, startTimePickerInst ) { $('#timepicker1').timepicker('option', { maxTime: { hour: startTimePickerInst.hours, minute: startTimePickerInst.minutes } }); }For timepicker1 and 2 its working fine.For dynamically created timepickers,I am not able to set mindate and max date.Can anyone help me... Hey, I need help with date, I have stored dates in my table in this format: i.e. 22.10.2011 but now use timestamp to store dates. Problem is with this query the WHERE clause will find dates in the old format and I want to change that to the new format. Code: [Select] for($i = $count; $i > 0; $i--) { $day = date("d.m.Y", mktime(0, 0, 0, date("m"), date("d") - $i, date("Y"))); $tmp = mysql_fetch_array(safe_query("SELECT count FROM ".PREFIX."counter_stats WHERE dates LIKE '%".$day."'")); $array[] = $tmp['count'] ? $tmp['count'] : 0; } Am I making sense ? Hey, I need help with my date & time string. I need to edit it do show in a string + also use it for calculating things like when the date has passed. The string is like this: Code: [Select] <?php $string = '2011-01-01 00:00 AM'; ?> So i wanted to check if there was a function that can automatically convert it, so it would say for example: Quote Sunday, 1st of January 2011 00:00 AM But at the same time compare $string against server time to see if the date has expired? Hope you can help What is the best way to insert this time stamp into mysql? This is the info I want... Example: Sunday, 28.1.11, 9:56 How would I also select time from the database using mysql? I have a batch script that reads from a timestamp.txt file to determine the last time it ran and I need to modify that by two hours. What happens is the script will run to look for changes in the county records and their server time is two hours different from mine. Code: [Select] $fr=fopen("xml/timestamp.txt",'r'); $mydate=fread($fr, 50); if ($incremental_updates == 1){ $default_template_file="xml/incremental_template.xml"; $default_config_name="xml/incremental.xml"; $contest=file_get_contents($default_template_file); $contest=str_replace("{DATE_TAG}", $mydate, $contest); $f=fopen($default_config_name,'w+'); fwrite($f, $contest); fclose($f); fclose($fr); $fw=fopen("xml/timestamp.txt",'w'); fwrite($fw, substr(date('c'), 0, 19)); fclose($fw); }else{ $default_config_name = "xml/full_update.xml"; } I tried making a time stamp update look like $cur_timestamp=date("Y-m-d H:i:s", time() +14400); which is correct but it doesn't write to the text file properly. Using the above fwrite($fw, substr(date('c'), 0, 19)); I get the correct results in the timestamp.txt file for my server time. I need it to be +14400 2011-05-25T08:27:51 would essentially become 2011-05-25T10:27:51 when it writes to the timestamp.txt I hope that makes sense. J Hi! The below dropdown will show dates/times every 15 minutes from 12am to 11:45pm for only 1 day. I want it to show for 5 days, anyway I can do this? Below code: Code: [Select] $start = strtotime('12:00am'); $end = strtotime('11:45pm'); echo '<select name="time">'; for ($i = $start; $i <= $end; $i += 900) { echo '<option>' . date('F j, Y, \a\t g:i a', $i); } echo '</select>'; Thanks for any help. I have a field set as datetime and want to compare that field to see if it is older then ten minutes. Can anyone help I am having a brain fart? the TIMESTAMP from mysql returns in this format: 2012-04-20 14:25:50 How could I rearrange this with PHP to read as: 04/20/2012 14:25 Thanks Hello, first time poster here and PHP newbie. I was directed here by the html forum. I need help adding a time + date stamp to videos I upload to my web page. I have searched this and other formus and not seen a similar query / solution. Here is my page: http://ob-kc.com/tl.html The thumbnails are linked to their respective timelapse videos. Between the thumbnail itself and the label (i.e. '7 am - 8 am') I would like to add 'Updated x/x/2011 @ xx:xx:xx' Any suggestions on the cleanest way to do this? Hugh hello i got this small function i`m working on to get the date of a month something like get current date - 1 but not sure how to handle jan month can someone help me please ? $month = date('m') - 1; $date_startt = date('Y').'-'.$luna.'-01'; $timestamp_start = strtotime($data_start); Hey guys, What i would like to create is the ability to calculate the difference between two dates / times. For example: 2010-12-13 10:00:00 to 2010-12-17 17:00:00 In a format of days / hours and minutes / seconds. However, I only want to calculate for an 9-5 work day, not the hours outside. Is this possible? If so, how would I go about creating something like this. Is it possible to convert time(); to date();? Are time zones when calling the date function automatically decided based on where you live? Or is that something that I have to implement--Because the time is wrong according to my time zone. |