get time difference in minutes in javascript

we created java-script function named “getTheDiffTime” using that function you will be able to fetch the time difference in various format.

javascript get time difference in minutes


function getTheDiffTime(dateone, datetwo,format){
//format = "Days", Hours, Minutes, Seconds
if(dateone > datetwo) {
var seconds = dateone.getTime() - datetwo.getTime();
} else {
var seconds = datetwo.getTime() - dateone.getTime();
}
var second = 1000, minute = 60 * second, hour = 60 * minute, day = 24 * hour;
if(format=="Days"){
var rformat = Math.floor(seconds / day);
seconds -= rformat * day;
//alert("days: "+rformat);
}else if(format=="Hours"){
// find the hours
rformat = translate(seconds / hour);
//alert("hours: "+rformat);
}else if (format=="Minutes"){
//find the mintues
rformat= translate(seconds / minute);
//alert("minutes: "+ rformat);
}else if(format=="Seconds"){
//find the seconds
rformat = translate(seconds / second);
//alert("seconds: "+rformat);
}

return rformat
//alert(rformat);

}

How to use this function here I am giving you the one good example.

I am going to get the current months minutes using this function.


//for calculating the current month in mintue -script
currentMonth = new Date();
plus_oneMonth = new Date();
plus_oneMonth.setMonth(plus_oneMonth.getMonth()+1);

getTheDiffTime(plus_oneMonth,currentMonth,"Minutes");

You will get return the minutes.

How to use the killall command on linux

Killall command is very useful in linux. You can stop or kill the all same processes.

killall command can used in Linux and Unix OS.

killall – kill processes by name

You can find the process name by using this command:
#ps -ef|grep firefox

for kill the process
#su
#ROOT_PASSOWRD
#killall firefox

Solved issue -Directory index forbidden by Options directive:

I want to change the default location of Apache folder which is (var/www/html).
I am using the Fedora as OS and apache 2 here. you can use following code with any linux box like centos or ubuntu. Here we solved the issue of directory.

When I inserted the following code in bottom of the httpd.conf file.
<VirtualHost *:80>
Options +FollowSymLinks
ServerAdmin siwan@yahoo.co.in
DocumentRoot /var/www/html/testfolder
ErrorLog logs/error_log_net
TransferLog logs/access_log_net
</VirtualHost>

When tried the http://localhost/ in browser, I got the default browser page.
Then I tried to look my apache error using following command:
#[root@localhost ]# tail -f /var/log/httpd/error_log

In apache error log I got following error.
[Wed Oct 07 15:59:50 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/testfolder/

I changed the AllowOverride option but nothing is happens. Then I read the welcome page text
“To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.”
I opend the welcome.conf file.

I found following lines in welcome.conf file.
<LocationMatch “^/+$”>
Options -Indexes
ErrorDocument 403 /error/noindex.html
LocationMatch>

I changed that to as follows:

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

<LocationMatch “^/+$”>
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

[/viral-lock]

That solve my problem. Some time your selinux will cause the issue so you need to deactivate the selinux.
Some time File permission will also cause the issue.
You can change the file permission using following command, go to that directory and run following command.
#chmod 777 *

You can use above commands on any linux box. Ubuntu, centos, redhat or on fedora box.. still solution will be same.

PHP if else statement- Normal and advanced

Here now I am giving you the normal code example.

$test = 100;

if ( $test == 100 ) {
echo “The if statement evaluated to true”;
} else {
echo “The if statement evaluated to false”;
}

If you want to use this in one line than use following code:

echo $testprint = ( $test == 100 ) ?  “The if statement evaluated to true” : “The if statement evaluated to false”;

This will gives you same output.

Now I am giving you the multiple IF else statment in very short way.

if ( one= true ){
if ( two=true){
echo “one”;
}else{
echo “two”;
}
}else{
echo “nothing”;
}

Short way:

$shortway = (one= true) ? (two=true ) ? “one” : ‘two’ ) : “nothing”;

Some accordion JS scripts samples

we collected some unique of accordion JS scripts samples. we personally tested the scripts. All scripts are based on jquery. Jquery accordion used by everyone.

I am suggesting following accordions:

Some accordion JS scripts samples

jQuery Accordion examples:
http://www.stemkoski.com/downloads/jquery-accordion-menu/example.htm
http://www.i-marco.nl/weblog/jquery-accordion-menu/
http://roshanbh.com.np/2008/06/accordion-menu-using-jquery.html
http://jqueryfordesigners.com/demo/simple-slide-demo.html
this has single ‘jquery-1.js’ (79KB) un-compressed version with first visible accordion, onclick backgroud color change

MooTools Accordion example:
http://davidwalsh.name/dw-content/accordion.php
this has single ‘moo1.js’ (133KB) un-compressed version with first visible accordion, onclick backgroud color change

YUI Accordion example:
http://www.hedgerwow.com/360/mwd/accordion/demo.php?page=3

Other:
http://www.switchonthecode.com/tutorials/javascript-tutorial-inline-sliding-panels

Page scroll up and down in javascript

Document or web-page scrolling is very easy through javascript. In this article we given code for Page scroll up and down in javascript. We used JS methods.

 Page scroll up and down in javascript

window.scrollBy(10,20); // horizontal and vertical scroll increments or decrements.

Using scrollBy function you can create custom event or function based on project requirement.

Here I am giving you the sample code: Up scrolling and down scrolling


//For Upscrolling:

function ScrollUp() {
window.scrollBy(0,100);
}

//For Down scrolling:
function ScrollDown() {
window.scrollBy(0,-100);
}

In same way you can create your own functions.

Solved :Error establishing a database connection

Many times I saw this message. “Error establishing a database connection”. That time I did not understand why this message is coming.

When started working on WordPress blog Plugins, Themes. Then I got to know about this error.
Whenever you mis-configured the wp-config.php file. You will this kind of error.

You need to Fill following information correctly:(dont forget to create database your own)
** The name of the database for WordPress */

define(‘DB_NAME’, ‘wordpress’);

/** MySQL database username */

define(‘DB_USER’, ‘root’);

/** MySQL database password */

define(‘DB_PASSWORD’, ”);

/** MySQL hostname */

define(‘DB_HOST’, ‘localhost’);

This will solve your problem.

send a variable value from an Iframe back to its parent

We have javascript code for how to send a variable value from an Iframe back to its parent? If you want fetch the variable value or send variable to parent page.

how to send a variable value from an Iframe back to its parent?

Use following code:
In Parent page use this copy paste folliwing javascript.


function showValue(testval)
{
alert(testval);
//here in parent page you call any other function as per your need.
}

In Iframe page use following code. In Iframe page use this copy paste folliwing javascript.


// Calls the function showValue in the parent object
// and passes the value of 't' to it
function passToParent(val)
{
var testval;
if ( (testval = window.parent) && (testval = testval.showValue) && ('function' == typeof testval || 'object' == typeof testval) ){
testval(val);
}
}

This will solve your problem.

How to install webmin on Fedora9

You can able to download webmin package through RPM only.
You can find the webmin RPM http://sourceforge.net/projects/webadmin/files/webmin/1.490/webmin-1.490-1.noarch.rpm/download
from this url.

Use following command for installing webmin
#rpm -Uvh webmin-1.490-1.noarch.rpm

This will install the webmin package on your fedora box.
Afer installation you will get following message.
Webmin install complete. You can now login to http://localhost.localdomain:10000/
as root with your root password.

Open this URL in browser http://localhost.localdomain:10000/

That sit.