Sunday 28 July 2019

How to compare dates greater than in php?



<?php
$today = date('d-m-Y'); // Date must be in 'd-m-Y' format
$date = "07-07-2020";

if(strtotime($date) < strtotime($today)){
   echo $date .' date is smaller than today '.$today .' date';
}else{
    echo $today .' date is larger than today '.$date .' date';
}
?>

Wednesday 10 July 2019

How do I set and get a cookie with jQuery?

<script type='text/javascript'>
function setCookie(key, value) {
         var expires = new Date();
         expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
         document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
setCookie('Name','Kishan');

function getCookie(key) {
          var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
          return keyValue ? keyValue[2] : null;
}
getCookie('Name');

// Output: "Kishan"
</script>

Wednesday 3 July 2019

How to import an SQL file using the command line in MySQL?









#Step1: Create just databse in your phpMyAdmin
 Ex: test_table.sql

#Step2: put sql databse file in bin folder
 Ex: E:\wamp64\bin\mysql\mysql5.7.26\bin\DB\test_table.sql

# Open CMD
# Step3: Change the directory folder current directory to mysql bin directory.
 C:\Users\kishanvk>CD E:\wamp64\bin\mysql\mysql5.7.26\bin ↲
 C:\Users\kishanvk>E: ↲
 E:\wamp64\bin\mysql\mysql5.7.26\bin>

# Step4: write below command line and in this cmd
 E:\wamp64\bin\mysql\mysql5.7.26\bin>mysql -u [Username] -p [DBNAME] < DB\[DBNAME.sql] ↲

 Ex: E:\wamp64\bin\mysql\mysql5.7.26\bin>mysql -u root -p test_table < DB\test_table.sql ↲

# Step5: Enter password
 Enter password:***** ↲

# Step6: You can see imported database in your phpMyAdmin