------- GET TIME WITH AM/PM VALUE ----
HTML:
<input type="time" name="newtime" autofocus="autofocus" required>
PHP :
$time = $this->input->post('newtime');
$newtime = date('h:i A', strtotime($time));
-------- SHOW RIGHT BOTTOM ALERT -----
HTML/PHP :
<?php if (isset($_SESSION['dnvalue'])) { ?>
<div class="alert alert-danger alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php
echo $_SESSION['dnvalue'];
unset($_SESSION['dnvalue']);
?></strong>
</div>
<?php }?>
CSS :
<style>
.alert {
position: fixed !important;
z-index: 99;
right: 30px;
bottom: 60px;
margin: 20px 0;
}
</style>
JS :
<script>
setTimeout(function() {
$('.alert').fadeOut('slow');
}, 2000);
</script>
------- GET DATA IN SELECT OPTIONS WITH AJAX/CI ----
HTML:
<select class="form-control" id="newtimes" name="servicetime" required> </select>
PHP :
public function alltimes()
{ $timedata = $this->user_model->get_joins('availabletimes','','','');
echo json_encode($timedata);
}
JS :
<script>
$(document).ready(function(){
$.ajax({
url: "<?php echo base_url('user/alltimes'); ?>",
success: function(result){
var timeObj = JSON.parse(result);
var j=0;
var timeslots='' ;
timeObj.forEach(function(opt) {
timeslots +="<option value='"+timeObj[j].id+"'>"+timeObj[j].time+"</option>";
j++;
});
$("#newtimes").html(timeslots);
}
});
});
</script>
--- FORMAT Date CONVERSION (12hr/ 24hr)
$gettime = '10:18 PM';
$newtime = date('h:i A', strtotime($gettime)); // 10:18 PM
$gettime = '10:18 PM';
$newtime = date('H:i A', strtotime($gettime)); // 22:18 PM
---- AJAX POST
var menuId = $( "ul.nav" ).first().attr( "id" );
var request = $.ajax({
url: "script.php",
method: "POST",
data: { id : menuId },
dataType: "html"
});
request.done(function( msg ) {
$( "#log" ).html( msg );
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
--- SELECT TIME GREATER THAN GIVEN TIME
SELECT * FROM availabletimes WHERE `time` >= 'GIVEN TIME'
---- SQL : http://www.zentut.com/sql-tutorial/sql-between/
HTML:
<input type="time" name="newtime" autofocus="autofocus" required>
PHP :
$time = $this->input->post('newtime');
$newtime = date('h:i A', strtotime($time));
-------- SHOW RIGHT BOTTOM ALERT -----
HTML/PHP :
<?php if (isset($_SESSION['dnvalue'])) { ?>
<div class="alert alert-danger alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php
echo $_SESSION['dnvalue'];
unset($_SESSION['dnvalue']);
?></strong>
</div>
<?php }?>
CSS :
<style>
.alert {
position: fixed !important;
z-index: 99;
right: 30px;
bottom: 60px;
margin: 20px 0;
}
</style>
JS :
<script>
setTimeout(function() {
$('.alert').fadeOut('slow');
}, 2000);
</script>
------- GET DATA IN SELECT OPTIONS WITH AJAX/CI ----
HTML:
<select class="form-control" id="newtimes" name="servicetime" required> </select>
PHP :
public function alltimes()
{ $timedata = $this->user_model->get_joins('availabletimes','','','');
echo json_encode($timedata);
}
JS :
<script>
$(document).ready(function(){
$.ajax({
url: "<?php echo base_url('user/alltimes'); ?>",
success: function(result){
var timeObj = JSON.parse(result);
var j=0;
var timeslots='' ;
timeObj.forEach(function(opt) {
timeslots +="<option value='"+timeObj[j].id+"'>"+timeObj[j].time+"</option>";
j++;
});
$("#newtimes").html(timeslots);
}
});
});
</script>
--- FORMAT Date CONVERSION (12hr/ 24hr)
$gettime = '10:18 PM';
$newtime = date('h:i A', strtotime($gettime)); // 10:18 PM
$gettime = '10:18 PM';
$newtime = date('H:i A', strtotime($gettime)); // 22:18 PM
---- AJAX POST
var menuId = $( "ul.nav" ).first().attr( "id" );
var request = $.ajax({
url: "script.php",
method: "POST",
data: { id : menuId },
dataType: "html"
});
request.done(function( msg ) {
$( "#log" ).html( msg );
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
--- SELECT TIME GREATER THAN GIVEN TIME
SELECT * FROM availabletimes WHERE `time` >= 'GIVEN TIME'
---- SQL : http://www.zentut.com/sql-tutorial/sql-between/
PHP SET INDIAN TIMEZONE
ReplyDeletedate_default_timezone_set("Asia/Kolkata");
$date = date('d-m-Y H:i:s');