Found 1060 Articles for PHP

Extract the Day / Month / Year from a Timestamp in PHP MySQL?

Samual Sam
Updated on 30-Jul-2019 22:30:24

893 Views

To extract the Day/Month/Year from a timestamp, you need to use the date_parse() function. The syntax as follows −print_r(date_parse(“anyTimeStampValue”));The PHP code is as follows −$yourTimeStampValue="2019-02-04 12:56:50"; print_r(date_parse($yourTimeStampValue));The snapshot of PHP code is as follows −The following is the output −Array ( [year] => 2019 [month] => 2 [day] => 4 [hour] => 12 [minute] => 56 [second] => 50 [fraction] => 0 [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => )The snapshot of the sample output −

How to specify Decimal Precision and scale number in MySQL database using PHPMyAdmin?

Chandu yadav
Updated on 30-Jul-2019 22:30:24

2K+ Views

You need to select a database when you are creating a table. Right now, I have a sample database. The snapshot is as follows:Now you need to give the table name as well as the number of columns you want:After that you need to press Go button. Now, the following section would be visible:The DECIMAL requires two parameter i.e. Total Number of Digit and second one is DigitAfterDecimalPoint.The structure of DECIMAL is as follows:DECIMAL(X, Y)Here, X is TotalNumberOfDigit and Y is DigitAfterDecimalPoint.Let us see an example:DECIMAL(6, 4)Above, we will be having 6 digit sand 2 digit safter decimal point. For ... Read More

imagecreatetruecolor() function in PHP

Arjun Thakur
Updated on 31-Dec-2019 08:05:48

934 Views

The imagecreatetruecolor() function creates a new true color image.Syntaximagecreatetruecolor (width , height )Parameterswidth: The image width.height: The image height.ReturnThe imagecreatetruecolor() function returns an image resource identifier on success, FALSE on errors.ExampleThe following is an example Live DemoOutputThe following is the output displaying the height and width of the new image:500 600ExampleLet us see another example with different height and width: Live DemoOutputThe following is the output displaying the height and width of the new image:450 300

imageconvolution() function in PHP

Chandu yadav
Updated on 31-Dec-2019 08:00:58

140 Views

The imageconvolution() functionSyntaxbool imageconvolution (img, matrix, div, offset )Parametersimg: Create image with imagecreatetruecolor() function.matrix: A 3x3 matrix is an array of three arrays of three floats.div: Divisor of the result of the convolution, used for normalization.offset: The color offset.ReturnThe imageconvolution() function returns True on success or False on failure.ExampleThe following is an exampleOutputThe following is the outputExampleLet us see another example with different parameter values for the same image. You can easily spot the difference now:OutputThe following is the output

imagecolormatch() function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:59:35

79 Views

The imagecolormatch() function forms the colors of the palette version of an image more closely match the true color versionSyntaxbool imagecolormatch ( img1, img2 )Parametersimg1: Create image with imagecreatetruecolor() function.img2: A palette image link resource pointing to an image. This image has the same size as img1.ReturnThe imagecolormatch() function returns TRUE on success or FALSE on failure.ExampleThe following is an example Live DemoOutputThe following is the output:1ExampleLet us see another example Live DemoOutputThe following is the output:1

imagecolortransparent() function in PHP

George John
Updated on 31-Dec-2019 07:58:19

332 Views

The imagecolortransparent() function is used to set the color of a transparent image.Syntaximagecolortransparent ( img, color )Parametersimg: Create image with imagecreatetruecolor() function.color: Color identifier created with imagecolorallocate().ReturnThe imagecolortransparent() function returns the identifier of the new transparent color. The return value is -1 if color is not specified and the image has no transparent color.ExampleThe following is an exampleOutputThe following is the output:

imagecolorresolve() function in PHP

Arjun Thakur
Updated on 31-Dec-2019 07:48:35

34 Views

The imagecolorresolve() function gets the index of the specified color or its closest possible alternative.Syntaximagecolorresolve (img , red , green , blue )Parametersimg: Image created with imagecreatetruecolor() function.red: The value of red component.green: The value of green component.blue: The value of blue component.ReturnThe imagecolorresolve() function returns the color index.ExampleThe following is an example Live DemoOutputThe following is the output:Array ( [0] => 128 [1] => 129 [2] => 130 )

imagecolorstotal() function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:47:13

63 Views

The imagecolorstotal() function gets the count of colors in an image's paletteSyntaximagecolorstotal (img)Parametersimg: Image created with imagecreatetruecolor().ReturnThe imagecolorstotal() function returns the number of colors in an image palette.ExampleThe following is an example Live DemoOutputThe following is the output:Number of Colors = 128

imagecolorset() function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:46:41

118 Views

The imagecolorset() function sets the color for the specified palette index. Using this create flood-fill-like effects in palleted images.Syntaximagecolorset ( img, index, red, green, blue, alpha )Parametersimg: Image created with imagecreatetruecolor() functionindex: The index in the palette imagered: Value of red componentgreen: Value of green componentblue: Value of blue componentalpha: The transparency if image.ReturnThe imagecolorset() function returns nothing.ExampleThe following is an exampleOutputThe following is the output:

imagecolorsforindex() function in PHP

George John
Updated on 31-Dec-2019 07:46:17

102 Views

The imagecolorsforindex() function gets the colors for an index.Syntaximagecolorsforindex ( img, index )Parametersimg: Creates an image with imagecreatetruecolor()Index: Set the color index.ReturnThe imagecolorsforindex() function returns an associative array with red, green, blue and alpha keys that contain the appropriate values for the specified color index.ExampleThe following is an example Live DemoOutputThe following is the output:array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }

Advertisements