1

I need to print the number in one font, and the year in another

 <?php $timestamp = get_field('date_time'); ?>

How to do it . help me please

  • Welcome to WPSE. For formatting dates and times you can find examples in the PHP date() documentation, php.net/manual/en/function.date.php. And please note that 3rd party plugins, such as ACF, are considered off-topic here on WPSE. It is highly recommended to contact the plugin author should you have any questions regarding the use and/or configuration of the plugin. – Antti Koskinen Sep 3 '19 at 9:14
  • thank you very match)))) – Kaizer Sep 3 '19 at 11:34
0

Here you can get separated data from timestamp using date(); function. you can apply different fonts each value.

 <?php 
    $timestamp = get_field('date_time');

    $day = date('d', $timestamp);
    $mon = date('m', $timestamp);
    $year = date('Y', $timestamp);

    echo "Day : ".$day."<br>";
    echo "Month : ".$mon."<br>";
    echo "Year : ".$year;
?>

if $timestamp value "1567503270" then output will be below.

Output :

Day : 03
Month : 09
Year : 2019

if get_field('date_time') return 15 june, 2019 then its timestap will be 1560629940. see below code for reference.

$timestamp = strtotime("15 june, 2019");

$day = date('d', $timestamp);
$mon = date('m', $timestamp);
$year = date('Y', $timestamp);

echo "timestamp : ".$timestamp."<br>";
echo "Day : ".$day."<br>";
echo "Month : ".$mon."<br>";
echo "Year : ".$year;

**Output**

timestamp : 1560629940
Day : 15
Month : 06
Year : 2019
  • thank you very match)))) – Kaizer Sep 3 '19 at 11:35
  • You're Welcome! – Chetan Vaghela Sep 3 '19 at 11:41
  • But if $timestamp value 15 june, 2019 ? – Kaizer Sep 3 '19 at 13:12
  • then you have to convert date into timestamp first. $timestamp = strtotime(get_field('date_time')); – Chetan Vaghela Sep 3 '19 at 17:50
  • he still infers 1970 for some reason.does not work anyway – Kaizer Sep 4 '19 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.