Monday, March 28, 2011

MySQL DATE_FORMAT() Function

Definition and Usage

The DATE_FORMAT() function is used to display date/time data in different formats.

Syntax

DATE_FORMAT(date,format)

Where date is a valid date and format specifies the output format for the date/time.
The formats that can be used are:
Format Description
%aAbbreviated weekday name
%bAbbreviated month name
%cMonth, numeric
%DDay of month with English suffix
%dDay of month, numeric (00-31)
%eDay of month, numeric (0-31)
%fMicroseconds
%HHour (00-23)
%hHour (01-12)
%IHour (01-12)
%iMinutes, numeric (00-59)
%jDay of year (001-366)
%kHour (0-23)
%lHour (1-12)
%MMonth name
%mMonth, numeric (00-12)
%pAM or PM
%rTime, 12-hour (hh:mm:ss AM or PM)
%SSeconds (00-59)
%sSeconds (00-59)
%TTime, 24-hour (hh:mm:ss)
%UWeek (00-53) where Sunday is the first day of week
%uWeek (00-53) where Monday is the first day of week
%VWeek (01-53) where Sunday is the first day of week, used with %X
%vWeek (01-53) where Monday is the first day of week, used with %x
%WWeekday name
%wDay of the week (0=Sunday, 6=Saturday)
%XYear of the week where Sunday is the first day of week, four digits, used with %V
%xYear of the week where Monday is the first day of week, four digits, used with %v
%YYear, four digits
%yYear, two digits




Example

The following script uses the DATE_FORMAT() function to display different formats. We will use the NOW() function to get the current date/time:

DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p')

DATE_FORMAT(NOW(),'%m-%d-%Y')

DATE_FORMAT(NOW(),'%d %b %y')


DATE_FORMAT(NOW(),'%d %b %Y %T:%f')

The result would look something like this:
Nov 04 2008 11:45 PM

11-04-2008

04 Nov 08

04 Nov 2008 11:45:34:243

Tuesday, February 22, 2011

How to get dropdownlist Label value in Javascript ?






Monday, February 14, 2011

CSS3 support for Internet Explorer 6, 7, and 8

Get Full URL

The PHP super global $_SERVER contains all the information you need to access various information about the URL and can even carry variables. Often you need to get the full URL of the page you are on and this requires piecing together several of the $_SERVER variables to get the whole URL.
Here we have done the work for you so you do not need to go searching through $_SERVER to find the correct super global variables to work with.

/****
How to get Full URL
***/
 function getFullURL()
 {
    /* Here we check for https*/
    $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
    /* return the full address */
    return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
 }

 /* TO GET URL CALL FUNCTION LIKE THAT*/

 echo getFullURL();
?>

Thursday, February 10, 2011

How to Submit a Form Using JavaScript

Generally, a form is submitted when the user presses a submit button. However, sometimes, you may need to submit the form programmatically using JavaScript.
JavaScript provides the form object that contains the submit() method. Use the ‘id’ of the form to get the form object.
For example, if the name of your form is ‘myform’, the JavaScript code for the submit call is:
document.forms["myform"].submit();

But, how to identify a form? Give an id attribute in the form tag
<form id='myform' action='formmail.pl'>
Here is the code to submit a form when a hyperlink is clicked:
<form name="myform" action="handle-data.php">
Search: <input type='text' name='query' />
<a href="javascript: submitform()">Searcha>
form>
<script type="text/javascript">
function submitform()
{
  document.myform.submit();
}
script>
if you want to want to study this in brief please follow the below link:
http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml


How to change the PHP version for subfolders or subdomains

  How to change the PHP version for subfolders or subdomains Setting a specific PHP version for a specific websites, subfolders or subdomain...