Skip to content
Advertisement

How do centralised and change the text to blue for my Display Time in PHP

currently, my code is this and I do not know how to make it centre and the text in blue.

$date = new DateTime("now", new DateTimeZone('Asia/Singapore') );      
$dateString =  $date->format('d-M-Y H:i A');
echo $dateString;

Below is a reference to what I’m referring to! sorry I’m very new to PHP
enter image description here

Advertisement

Answer

The simplest way is to echo out the HTML you want:

echo "<span style='color: blue; text-align: center'>$dateString</span>"

If you have CSS class specified then you swap out the style attribute for a class and get the same effect.

 echo "<span class='some-class'>$dateString</span>"
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement