PHP Articles

Page 63 of 81

Comparison of dates in PHP

Alok Prasad
Alok Prasad
Updated on 15-Mar-2026 7K+ Views

Comparing two dates in PHP is straightforward when both dates are in a similar format, but PHP may fail to analyze dates when they are in different formats. In this article, we will discuss different approaches to date comparison in PHP using simple operators, the strtotime() function, and the DateTime class. Case 1: Simple Comparison with Same Format You can compare dates using simple comparison operators if the given dates are in the same format ? 2018-11-24 is older than 2019-03-26 Here we declared two dates in the same Y-m-d ...

Read More

Extracting only date from datetime field in MySQL and assigning it to PHP variable?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 793 Views

In PHP, you can extract only the date from a MySQL datetime field using the DateTime class. This is useful when you need to display or process only the date portion without time information. Syntax DateTime::createFromFormat("Y-m-d H:i:s", yourDateTimeValue)->format("yourFormatSpecifier"); Example Here's how to extract only the date from a MySQL datetime value ? 13/02/2018 Different Date Formats You can format the extracted date in various ways by changing the format specifier ? Y-m-d format: 2018-02-13 F j, Y format: February ...

Read More

How to add auto-increment to column in MySQL database using PhpMyAdmin?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 10K+ Views

You can add auto_increment to a column in MySQL database with the help of ALTER command. The syntax is as follows − ALTER TABLE yourTableName MODIFY yourColumnName INT NOT NULL AUTO_INCREMENT; Using PhpMyAdmin To open PhpMyAdmin on localhost, you need to type the following URL in your browser − localhost/phpmyadmin The PhpMyAdmin interface appears as follows − phpMyAdmin Database: AutoIncrementDemo Table: AutoIncrementDemo Field: UserId | Type: INT | Primary Key ...

Read More

imagecolorstotal() function in PHP

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 103 Views

The imagecolorstotal() function returns the number of colors in an image's palette. This function only works with palette−based images (like GIF or PNG with limited colors), not true color images. Syntax imagecolorstotal($image) Parameters $image − An image resource created by one of the image creation functions like imagecreatefromgif() or imagecreatefrompng(). Return Value Returns the number of colors in the image's palette as an integer. For true color images, it returns 0. ...

Read More

How can I get enum possible values in a MySQL database using PHP?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

You can get the enum possible values in a MySQL database using PHP by querying the INFORMATION_SCHEMA.COLUMNS table. This approach allows you to extract enum values programmatically without hardcoding them in your application. Database Setup First, let's create a sample table with an ENUM column ? CREATE TABLE EnumDemo ( Id int, Color ENUM('RED','GREEN','BLUE','BLACK','ORANGE') ); Method 1: Basic Query to Get Enum Values Use the INFORMATION_SCHEMA.COLUMNS table to retrieve the enum definition ? enum('RED','GREEN','BLUE','BLACK','ORANGE') Method 2: Extract Individual Enum Values Parse the enum string to get individual values as an array ?

Read More

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

Samual Sam
Samual Sam
Updated on 15-Mar-2026 962 Views

To extract the Day/Month/Year from a timestamp in PHP, you can use the date_parse() function. This function parses a date string and returns an associative array with detailed date and time components. Syntax print_r(date_parse("anyTimeStampValue")); Example Let's extract day, month, and year from a timestamp using date_parse() ? Array ( [year] => 2019 [month] => 2 [day] => 4 [hour] => 12 [minute] => 56 ...

Read More

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

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 2K+ Views

When working with DECIMAL data types in MySQL through PHPMyAdmin, you need to specify both precision and scale to properly store monetary values or other exact numeric data. This tutorial shows you how to configure decimal precision and scale using PHPMyAdmin interface. Understanding DECIMAL Precision and Scale The DECIMAL data type requires two parameters: DECIMAL(precision, scale) Where: Precision (X) − Total number of digits that can be stored Scale (Y) − Number of digits after the decimal point Example of DECIMAL Usage For DECIMAL(6, 4): Total digits: 6 Digits ...

Read More

imageconvolution() function in PHP

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 185 Views

The imageconvolution() function in PHP applies a convolution matrix to an image resource. This function is used for image filtering effects like sharpening, blurring, edge detection, and embossing. Syntax bool imageconvolution(resource $image, array $matrix, float $div, float $offset) Parameters image − An image resource created by functions like imagecreatetruecolor() or imagecreatefromgif(). matrix − A 3x3 matrix represented as an array of three arrays, each containing three float values. div − The divisor used for normalization of the convolution result. Used to control the brightness of the output. offset − Color offset value added ...

Read More

imagecolormatch() function in PHP

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 126 Views

The imagecolormatch() function adjusts the colors of a palette image to more closely match those of a true color image. This function is useful when you need to optimize a palette-based image to better represent the original true color version. Syntax bool imagecolormatch(resource $img1, resource $img2) Parameters img1 − A true color image resource created with imagecreatetruecolor() function. img2 − A palette image resource with the same dimensions as img1. This image's palette will be modified to match img1. Return Value The function returns TRUE on success or FALSE on ...

Read More

imagecolortransparent() function in PHP

George John
George John
Updated on 15-Mar-2026 364 Views

The imagecolortransparent() function in PHP sets a specific color in an image to be transparent. This is particularly useful when creating images with transparent backgrounds or when overlaying images. Syntax imagecolortransparent(resource $image [, int $color]) Parameters image − An image resource created by functions like imagecreatetruecolor() or imagecreate(). color (optional) − Color identifier created with imagecolorallocate(). If not specified, returns the current transparent color. Return Value The function returns the identifier of the new transparent color when a color is set. If no color parameter is provided, it returns the ...

Read More
Showing 621–630 of 802 articles
« Prev 1 61 62 63 64 65 81 Next »
Advertisements