Skip to content

Instantly share code, notes, and snippets.

View Sivamanim's full-sized avatar

Sivamani Sivamanim

  • Coimbatore
View GitHub Profile
@Sivamanim
Sivamanim / index.php
Created September 23, 2017 06:55
Time different between two time zone
<?php
$db_time = '2017-09-21 12:00:00 PM';
$db_timezone = 'Asia/Kolkata';
$user_timezone = 'America/New_York';
date_default_timezone_set($db_timezone); //Change default timezone to old timezone within this function only.
$originalTime = new DateTime($db_time);
$originalTime->setTimeZone(new DateTimeZone($user_timezone)); //Convert to desired TimeZone.
date_default_timezone_set($user_timezone) ; //Reset default TimeZone according to your global settings.
@Sivamanim
Sivamanim / PHP date
Created November 16, 2017 16:30
PHP date
<?php
// Current date
echo date('Y-m-d');
// Current time
echo date('H:i a');
// Date replated questions refer following link
?>http://php.net/manual/en/function.date.php
@Sivamanim
Sivamanim / distance between two latitude and longitude using php
Last active November 21, 2017 06:46
distance between two latitude and longitude using php
/* PHP */
//Get latitude and longitude from geo data
$latitudeFrom = '11.016844';
$longitudeFrom = '76.955832';
$latitudeTo = '11.232103';
$longitudeTo = '77.106716';
$unit = 'z';
$theta = $longitudeFrom - $longitudeTo;
@Sivamanim
Sivamanim / Google Static Map
Created November 21, 2017 10:01
Google Static Map using latitude and longitude
// Use below link with custome latitude and longitude for Static map
https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false
<?php
$db_username = ''; //username
$db_password = ''; //password
//path to database file
$database_path = $_SERVER["DOCUMENT_ROOT"] . "\access\accessdatabase.accdb";
//check file exist before we proceed
if (!file_exists($database_path)) {
die("Access database file not found !");
}
Video Details
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={video_ID}&key={Google_APIKEY}
Video view,like and dislike count details
https://www.googleapis.com/youtube/v3/videos?part=statistics&id={video_ID}&key={Google_APIKEY}
ALTER TABLE shop_menu
ADD CONSTRAINT shop_id
FOREIGN KEY (shop_id) REFERENCES shop_details(id)
<?php
$utc = '2018-04-10 12:51:59 UTC';
$dt = new DateTime($utc);
$tz = new DateTimeZone('Asia/Kolkata'); // or whatever zone you're after
$dt->setTimezone($tz);
echo $dt->format('Y-m-d H:i:s');
exit;
$array = Array
(
[0] => Array
(
[plan] => basic
)
[1] => Array
(
[plan] => small
if(jQuery.inArray("test", myarray) !== -1)