Grab the RSS feed

Convert the time zone in PHP

In my application the client want to display the timezone in PST.
But default the time is displayed in MST.That is we get the time from server and displayed in aparticular page.
But the client want to show only in the particular page in PST.So I get the Program from PHP http://www.php.net/manual/en/function.date.php and use it.

Here I need to change the America/New_York to America/Los_Angels and it display the PST time

If you want it to display in different format change the argument in $format.Instead of g:i A T use D,h A T etc.
#

< ?php
function date_at_timezone($format, $locale, $timestamp=null){

if(is_null($timestamp)) $timestamp = time();

//Prepare to calculate the time zone offset
$current = time();

//Switch to new time zone locale
$tz = date_default_timezone_get();
date_default_timezone_set($locale);

//Calculate the offset
$offset = time() - $current;

//Get the date in the new locale
$output = date($format, $timestamp - $offset);

//Restore the previous time zone
date_default_timezone_set($tz);

return $output;

}

//Examples
$t = time();

print date("g:i A T", $t); //4:16 PM PDT
print date_at_timezone("g:i A T", "America/New_York", $t); //7:16 PM EDT
print date_at_timezone("g:i A T", "Pacific/Samoa", $t); //12:16 PM SST
print date("g:i A T", $t); //4:16 PM PDT
? > 

Leave the comments to improve us….
Click Here to download as word document...

Expand the tree without Disclosure Icon and change the tree Icons

Today I face the problem of open the tree without using the disclosure open and Close Icon and also they need to changr the First folder Icon only.

Then I need to make the search and find out code for open the tree without disclosure Icon and also I merged the code for change the tree’s first folder.

I give the coding below…

You can use it.
Thanks for flexexamples

< ?xml version="1.0" encoding="utf-8"?> 
< !-- http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/ --> 
< mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"> 

< mx:Script> 
< ![CDATA[
import mx.collections.ICollectionView;
import mx.events.ListEvent;

< !----- Function to change the folder Icon of first node ----!> 
[Embed("assets/folder_table.png")]
private var FolderTableIcon:Class;

private function init():void 
{
var nodeOne:XML = xmlListColl.getItemAt(0) as XML;
tree.setItemIcon(nodeOne, FolderTableIcon, FolderTableIcon);

}
< !---Function for open the tree without disclosure Icon ---!> 
private function tree_itemClick(evt:ListEvent):void {
var item:Object = Tree(evt.currentTarget).selectedItem;
if (tree.dataDescriptor.isBranch(item)) {
tree.expandItem(item, !tree.isItemOpen(item), true);
}
}

private function tree_labelFunc(item:XML):String {
var children:ICollectionView;
var suffix:String = "";
if (tree.dataDescriptor.isBranch(item)) {
children = tree.dataDescriptor.getChildren(item);
suffix = " (" + children.length + ")";
}
return item[tree.labelField] + suffix;
}
]]> 
< /mx:Script> 

< mx:XML id="dp"> 
< root> 
< folder label="One"> 
< folder label="One.A"> 
< item label="One.A.1" /> 
< item label="One.A.2" /> 
< item label="One.A.3" /> 
< item label="One.A.4" /> 
< item label="One.A.5" /> 
< /folder> 
< item label="One.1" /> 
< item label="One.2" /> 
< /folder> 
< folder label="Two"> 
< item label="Two.1" /> 
< folder label="Two.A"> 
< item label="Two.A.1" /> 
< item label="Two.A.2" /> 
< /folder> 
< /folder> 
< /root> 
< /mx:XML> 

< mx:Tree id="tree"
dataProvider="{dp}"
showRoot="false"
labelField="@label"
labelFunction="tree_labelFunc"
width="300"
rowCount="6"
itemClick="tree_itemClick(event);" /> 

< /mx:Application> 


You can also download this coding from click here

Leave the comments to Improve us….

Happy X mas

Hello friends,

Happy Christmas.And also I wish you the happy nw yaer.....

This new year will bring you to the happiest moment .......

Set maxLength Using Javascript

Hello friends,

Sometimes we need to set the maxlength for textbox or textarea depend upon the value selected.
For example if you select the country then we need to set the zip code length depend upon the country.
If the country selection is depend upon the ajax it is easy to set the length.

For example in US the zip code contain only 5 characters.But in india this going to be six.
It is simple and easiest way in the javascript.Set the maximum length by using the following code...

  
document.getelementid('textbox1").maxLength=10

Click Here to download as PDF format..

Leave the comment to improve us...

TechnoRati

This is a post for Technorati verification TW7YARVHC2ZT

Page redirection Using PHP

The simplest and easiest way is header redirection in PHP.

The Header redirection has the PHP following syntax.

void header ( string $string [, bool $replace = true [, int $http_response_code ]] )

Whenever you need to redirect the page you can use this.

Today I need to solve the issue that contains this problem.

My situation is when the user get the Message it will open in the Jquery Modal box with the button read and delete. When they get the popup and click the button it will redirect to the page with the url of ?MessageID=’something.’

Even if delete the message it will called in the ajax and the URL is NOT cleaned .Then after delete the ID also going to be cleared in Database. IF the user going to refresh after delete the message it gives the SQL error because of there is no such a ID.

In that situation I use the above header redirection. That is I check whether the ID is NULL. If it is NULL then I redirect to the another URL.

Otherwise I can do the Operation as Read a Message.


Leave the comments to improve ourself………….

For more Information visit this site

Click Here to download as a PDF format

Concatenation in PHP

The easiest one operation in PHP is the concatenation operation.

This is need only one dot operator for the concatenation .Whenever we need the concatenation it tooks the simple dot and append the variable we need.

The below code simply illustrates the two methods of Concatenation.

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 
< html xmlns="http://www.w3.org/1999/xhtml" > 
< head > 
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" / > 
< title > concatenation< /title > 
< /head > 

< body > 
< ?
$var1=' I am';
$var2=' a';
$var3=' boy';
echo $var1.$var2.$var3;
echo "< br/ > ";
/************otherwise we can use like the below operation**************/
$var4=' Hello ';
$var4.='world';
echo $var4;

? > 
< /body > 
< /html > 



Leave the comments to improve ourself…..

Click Here to download as PDF Format

 
Real Time Web Analytics