Here is the code I have in WordPress template's PHP file with some variables. Actually it is a stripped down replica of Warp Framework's warp/config.php.
<?php
return array(
'month' => 'Current month',
'year' => 'Current year'
);
Is it possible to replace Current month and Current year texts with actual PHP date output?
I know how to implement PHP date into a PHP page but I have no idea how to place it here.
Try this
<?php
return array(
'month' => date('m'),
'year' => date('Y')
);
?>
That should give you what you need.
Basically, using PHP's date() function, you can output the current date in whichever format you need by specifying the format mask in it's instantiation.
This page of the PHP.net site will help explain the many different methods of creating a date. PHP.net date() Function
If the previous code creates an array called for instance $date and you just want to change it after it was created, you could do so as follows:
$date['month'] = date('m');
$date['year'] = date('Y');
If however you want to modify the code that is creating the array, then guyver4mk's answer is on point:
<?php
return array(
'month' => date('m'),
'year' => date('Y')
);
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With