1 0 Tag Archives: php
post icon

Set PHP Date Time local to Asia/Calcutta (Indian Standard Time)

$timezone = “Asia/Calcutta”;
date_default_timezone_set($timezone);
$date = date(‘Y-m-d’);
$time = date(‘H:i:s’);

Leave a Comment
post icon

How to read CSV (Comma Separated Files) line by line in PHP?

CSV is plain text file, which means you can open it notepad or anyother text editor.
CSV file stores tabular data (numbers and text) in plain-text form.

$file_handle = fopen(“csv_file_name.csv”, “r”);

while (!feof($file_handle) ) {

$line_of_text = fgetcsv($file_handle, 1024);

print $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . “
“;

}

fclose($file_handle);

Leave a Comment
post icon

php difference between two dates

<?php
$startDate =”1-1-2011″;
$endDate = “2-2-2011”;
$days = (strtotime($endDate) – strtotime($startDate)) / (60 * 60 * 24);
print $days;
?>

Leave a Comment
post icon

Adding unique name for uploaded files

$a = uniqid();

$a = “free-news-agency-“.$a;
$filename = $_FILES[image_field][name];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$name = $a.”.”.$ext;

this is for using upload.class.php from http://www.verot.net/php_class_upload.htm

Leave a Comment
December 30, 2011
post icon

Screen resolution using java script and using it in php

use this code to set screen resolution into a cookie

< script language=”javascript”>
<!–
writeCookie();
function writeCookie()
{
var today = new Date();
var the_date = new Date(“December 31, 2023”);
var the_cookie_date = the_date.toGMTString();

var the_cookie = “users_resolutionx=”+ screen.width ;
var the_cookie = the_cookie + “;expires=” + the_cookie_date;
document.cookie=the_cookie

var the_cookie = “users_resolutiony=”+ screen.height ;
var the_cookie = the_cookie + “;expires=” + the_cookie_date;
document.cookie=the_cookie

}
//–>
</script>

 

use this code to access screen size

 

<? php

$x = $_COOKIE[users_resolutionx];
$y = $_COOKIE[users_resolutiony];
?>

Leave a Comment
post icon

Round Corner box with CSS “Border-radius”

Have you(programmer) ever need a round corner box around some text. What you do

ask designer to make a round corner image and use it as a <DIV> backround, right?

Now with CSS3, IE9, FF7+, you can use CSS to define a “round corner box” using only CSS.

//css

<style>
.round{
border-radius: 25px;
background-color:#CCC;
width:300px;
height:300px;
padding-top:5px;
padding-left:5px;
}
</style>

 

//HTML/PHP

<div class=”round”>This is round corner box</div>

 

//output

CSS Round Corner Box using DIV

 

Leave a Comment
post icon

Redirect to another page – JavaScript

<script type="text/javascript">
<!--
window.location = "http://www.example.com/"
//-->
</script>

This code can be used to redirect to another page, PHP progammer can use this code to redirect to another page
where PHP code

header("location:http://www.inoxh.com");exit;

does not work, or gives error.
Leave a Comment
October 30, 2011