Day number of week from date or day in php

In one of the previous posts I described how to get day from date in PHP. The same function can be used to find the day number of the week. In this post I have given examples of how to find “day number of week” from both date and day name.

For example:

20/8/2015 is Thursday, which is 4th day of the week.

 

Find current day number of week

 

Find day number of week from date

 

Find day number of week from day

Other than date, day number of week can also be found by the “date name”.

 

 

Useful Links:

day of the week to day number

Finding the number of the day in a week in PHP from a date

Read More

Gzip compression wordpress

Gzip compression can be enabled in WordPress. There are several ways to enable gzip compression in WordPress. Gzip compression reduces 60-70% of the page size.

Enable gzip compress using WordPress plugins

 

1. WP Super Cache

WP Super Cache can be used for gzip compression wordpress. It has a feature in “Advanced” tab from where compression can be enabled.

gzip compression wordpress wp-super-cache

 

2. W3 Total Cache

W3 Total Cache is another wordpress plugin which can work for gzip compression. gzip compression via W3 Total Cache in the following way. Open performance > Browser Cache, and then check 

gzip compression wordpress wp-total-cache

 

 

Enable gzip compression through htaccess

There is another way other than plugins to enable gzip compression. gzip compression can be enabled using htaccess file by adding the following code into htaccess file.

 

Read More

Gzip Compression htaccess

Compression is important in a sense that compressed pages take less time to load. Most of the sites enable gzip compression because it compresses around 60 to 70 percent. Thus lesser bandwidth is required to download pages. It is also good for SEO because it reduces the response time.

 

How to enable Gzip compression

In order to optimize you website, gzip compression can be enabled by adding following code in .htaccess file.

 

Useful Links:

Enable gzip compression

Read More

Customize Scrollbar CSS

You might have noticed that some webpages have customized scrollbars. Here you will find out how to customize scroll-bars on your web-pages.

Basically customization of scroll-bars is composed of several different components. Important components of scroll-bar are mentioned below:

  • Scrollbar-track
  • Scrollbar-thumb
  • Scrollbar-button
scrollbar-thumb is the bar which moves for taking page up and down.
scrollbar-track is a track on which scroll-bar moves.

1. Global setting.

It will change all the scroll-bars on webpage

Lets share a code chunk of customizing all the scrollbars on page.

 

2.Customize scrollbar of div

First of all make a a div in HTML and place enough content into it.

HTML part

CSS part

Note:

  • The <div> with class .scrollable is given height of 300px, and when the content in it moves down to +300px , a scrollbar will appear.
  • scrollbar-button will show buttons(up-down arrows) at top and bottom of track

 

Output:

customize scrollbar

Useful Links:

Read More

CIRCULAR IMAGES using CSS3

It is now very easy to display circled , circular images using CSS3 on web pages. The feature to be used is border-radius . border-radius gives curves to borders of element and thus can produce rounded or circular images.

 

How Circular Images using CSS3 are produced?

Circular images using CSS3 can be produced in a special case. The special case is that the original image should be perfect square. If height and width of image are equal and border-radius is applied correctly, circular image is displayed from squared image.

 

Following is the shared code chunk for producing circular images using CSS3

 

circular image

 

Read More

PUSH DATA IN ARRAY PHP

Here is a very helpful function in php through which you can push data into array. Data will be inserted at the end of array, just like in the stack.

The function is array_push()

Example:

How to push data in array PHP

If you save some data into array;

 

$arr = array(“a”,”b”);

 

and now you can easily add other data into it using array_push() function as follows.

 

array_push($arr,”c”,”d”);

 

Now to verify this you can simply use print_r() function.

 

print_r($arr);

 

Output

Output clearly shows that data elements “c” and “d” have been pushed into array “$arr”.

Useful Links:

PHP Manual for array_push

Read More

JQUERY CNIC FORMAT

The following script shows how to auto-set the format of CNIC number using jQuery while typing in the input field.

Format of CNIC is xxxxx-xxxxxxx-x

While typing numbers of your CNIC, “-” should be automatically inserted at correct places.
For this purpose you will have to use keydown function.

 

 

 

$(this).val().length gets the length of string typed.

 

 

Read More

CSS3 BACKGROUND GRADIENT

CSS3 gradient provides to produce background with multiple colors. Two or more than two color can be combined to produce CSS3 background gradient effect.

Mainly two types of gradients are available in CSS3 background gradient.

  1. Linear gradient
  2. Radial gradient

Examples of both CSS3 gradients are given below

 

 

Linear Gradient

 

 

css3 background gradient linear

 

as both colors are set to 50% so there for half of div is taken by one color and other half by another .

 

Lets make slight modification in the above style

css3 background gradient linear

 


 

Radial Gradient

css3 background gradient radial

 

 


 

Useful Links:

css3 gradient at w3schools

Read More