Adding dynamic content in php
PHP tho dynamic web pages create chestunnappudu, page lo current date and time ni automatically display cheyadam oka common requirement. Static content laga date and time ni manually type cheyakunda, PHP date and time functions use chesi current date and time ni webpage lo dynamically display cheyochu.
PHP lo date() function ni use chesi present day, month, year, hours, minutes, seconds mariyu AM or PM information ni display cheyavachu. Date format lo different characters ni use chesi manaki kavalsina format lo date and time ni show cheyochu.
For example, date(“d-m-Y”) use cheste day, month and four-digit year format lo date vastundi. date(“h:i:s A”) use cheste hours, minutes, seconds and AM or PM tho current time display avutundi.
Ee article lo PHP lo dynamic date and time ni webpage lo ela display cheyalo, date() function syntax enti, different date and time formats ela use cheyalo simple examples tho telusukundam.
Adding dynamic content means we are adding time and date to that web page.In php we are using date function for both time and date.Here is the two different syntax for the date and time to print on the web page. Date shows the present day , month and year.In that date function we can also find present time with hours , minutes,seconds .we can also know AM or PM along with that time.
What is Dynamic Content in PHP?
Dynamic content ante webpage lo information automatic ga change avvadam. PHP server-side language kabatti, server lo PHP code execute ayina tarvata generated result browser lo display avutundi.
For example, website lo:
Today’s Date: 23-09-2026
Current Time: 08:30:25 PM
lanti information ni manually update cheyyalsina avasaram ledu. PHP date() function ni use cheste current date and time automatic ga generate avutayi.
Example 1: Display Current Date and Time
<?php
echo “Today Date: ” . date(“d-m-Y”) . “<br>”;
echo “Current Time: ” . date(“h:i:s A”);
?>
Output:
Today Date: 23-09-2026
Current Time: 08:30:25 PM
Explanation:
Ee program lo date(“d-m-Y”) current date ni day-month-year format lo display chestundi. date(“h:i:s A”) current time ni hours, minutes, seconds and AM/PM tho display chestundi.
<br> use cheyadam valla date and time separate lines lo display avutayi.
Example 2: Display Date in Different Formats
<?php
echo “Format 1: ” . date(“d-m-Y”) . “<br>”;
echo “Format 2: ” . date(“Y-m-d”) . “<br>”;
echo “Format 3: ” . date(“d/m/Y”);
?>
Output:
Format 1: 23-09-2026
Format 2: 2026-09-23
Format 3: 23/09/2026
Explanation:
Ee example lo same current date ni three different formats lo display chestunnam.
d-m-Y → 23-09-2026
Y-m-d → 2026-09-23
d/m/Y → 23/09/2026
Manaki website requirement batti different date formats ni select cheskovachu.
Example 3: Display Current Time
<?php
echo “Current Time: ” . date(“h:i:s A”);
?>
Output:
Current Time: 08:30:25 PM
Explanation:
Ee program lo h hours ni, i minutes ni, s seconds ni and A AM or PM ni display chestayi.
12-hour format badulu 24-hour format kavali ante H use cheyochu.
Example:
<?php
echo “Current Time: ” . date(“H:i:s”);
?>
Output:
20:30:25
Example 4: Display Day and Month Name
PHP date() function tho day and month names kuda display cheyochu.
<?php
echo “Day: ” . date(“l”) . “<br>”;
echo “Month: ” . date(“F”);
?>
Output example:
Day: Wednesday
Month: September
Explanation:
Ikkada l use cheste complete day name display avutundi. F use cheste complete month name display avutundi.
Example 5: Create a Simple Welcome Message
Date and time ni website welcome message tho kalipi kuda use cheyochu.
<?php
echo “Welcome to our website!<br>”;
echo “Today is ” . date(“l, d F Y”) . “<br>”;
echo “Current time is ” . date(“h:i A”);
?>
Output example:
Welcome to our website!
Today is Wednesday, 23 September 2026
Current time is 08:30 PM
Explanation:
Ee example lo normal text tho paatu PHP date() function ni use chesi current day, date, month, year and time ni dynamic ga display chestunnam.
Date syntax in php
date(“d-m-y”);
In this syntax d :today’s day
M:month
Y-year
Eg:-19-06-2026
Time syntax in php:
date(“h:i:s A”);
Here h:hours
i:minutes
s:seconds
A:AM or PM.
Program for dynamic content in php:
<?php
echo “good morning”.”<br>”;
echo “Today date is : ” . date(“d-m-y”).”\n”;
echo “present time is :” . date(“h:i:s A);
?>
Output:
good morning
Today date is : 19-06-2026
Present time is: 04:30:23 AM.
Explanation:
E php code lo manam echo lo good morning rasamu kabatti first line lo adhi print avuthundi.danni pakkana concatenate . Vadamu kabatti a break concatenate ayyi next line loki vastundi.a second line lo date daani tharwatha time vastundi.
Manam dynamic content in php lo date and time ni enter chesamu.date vachedi e roju date display chestadi .time hours , minutes, seconds and AM or PM tho saha ivva danaki AM or PM lowercase lo kavali ante akkada uppercase lo unna A ni lowercase lo raste a ani raste time pakkana lowercase lo vastundi..
3 thoughts on “Adding dynamic content in php”