title: How to display current date in php?
body: <p>I am using the wordpress plugin &quot;<a href="https://de.wordpress.org/plugins/woocommerce-gift-coupon/" rel="nofollow noreferrer">WooCommerce Gift Coupon</a>&quot; which generates a PDF sent as attachment to the customer via mail. I want to display the current date in that PDF and already found the php file to edit (mail-template.php).</p>
  <p>I tried to place the following code at several places within the body tag with no success:</p>
  <pre><code>&lt;?php
      $currentDateTime = date('Y-m-d H:i:s');
      echo $currentDateTime;
  ?&gt;
  </code></pre>
  <p>I also tried it without opening and closing php tags. I either get an error or it displays the code as it is in the PDF document.</p>
  <p>Here is the full code of mail-template.php:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  /**
   * WooCommerce Gift Coupon Mail Template
   *
   * Sets up the email template
   *
   * @author      WooCommerce Gift Coupon
   * @package     WooCommerce Gift Coupon/Mail Template
   */
  
  if ( ! defined( 'ABSPATH' ) ) {
      exit;
  }
  
  /**
   * Generate HTML PDF.
   *
   * @param array $data Coupon data.
   * @param bool  $preview Check if is preview.
   * @return string
   */
  function woocommerce_gift_coupon_generate_pdf_mail( $data, $preview = false ) {
      $woocommerce_gift_coupon_hide_amount         = get_option( 'woocommerce_gift_coupon_hide_amount' );
      $woocommerce_gift_coupon_show_logo           = get_option( 'woocommerce_gift_coupon_show_logo' );
      $woocommerce_gift_coupon_logo                = get_option( 'woocommerce_gift_coupon_logo' );
      $woocommerce_gift_coupon_info_paragraph_type = get_option( 'woocommerce_gift_coupon_info_paragraph_type' );
      $woocommerce_gift_coupon_info_paragraph      = get_option( 'woocommerce_gift_coupon_info_paragraph' );
      $woocommerce_gift_coupon_info_footer         = get_option( 'woocommerce_gift_coupon_info_footer' );
      $woocommerce_gift_coupon_title_type          = get_option( 'woocommerce_gift_coupon_title_type' );
      $woocommerce_gift_coupon_title_h             = get_option( 'woocommerce_gift_coupon_title_h' );
      $woocommerce_gift_coupon_subject             = get_option( 'woocommerce_gift_coupon_subject' );
      $woocommerce_gift_coupon_bg_color_header     = get_option( 'woocommerce_gift_coupon_bg_color_header' );
      $woocommerce_gift_coupon_bg_color_footer     = get_option( 'woocommerce_gift_coupon_bg_color_footer' );
      $woocommerce_gift_coupon_bg_color_title      = get_option( 'woocommerce_gift_coupon_bg_color_title' );
      $title_coupon                                = $woocommerce_gift_coupon_title_h;
      $description_coupon                          = wpautop( $woocommerce_gift_coupon_info_paragraph );
  
      // Convert logo to base64.
      if ( !empty( $woocommerce_gift_coupon_logo ) ) {
          $woocommerce_gift_coupon_logo_type = pathinfo( $woocommerce_gift_coupon_logo, PATHINFO_EXTENSION );
          $woocommerce_gift_coupon_logo_data = file_get_contents( $woocommerce_gift_coupon_logo );
          if ( !empty( $woocommerce_gift_coupon_logo_type ) &amp;&amp; !empty( $woocommerce_gift_coupon_logo_data ) ) {
              $woocommerce_gift_coupon_logo_base64 = 'data:image/' . $woocommerce_gift_coupon_logo_type . ';base64,' . base64_encode( $woocommerce_gift_coupon_logo_data );
          }
      }
  
      if ( empty( $preview ) ) {
          // Get title or description coupon.
          if ( $woocommerce_gift_coupon_title_type &gt; 0 || $woocommerce_gift_coupon_info_paragraph_type &gt; 0 ) {
              $data_coupon = get_post( $data['coupon_id'] );
              if ( ! empty( $data_coupon ) ) {
                  // Get custom title or product coupon title.
                  if ( $woocommerce_gift_coupon_title_type &gt; 0 ) {
                      $title_coupon = $data_coupon-&gt;post_title;
                  }
                  // Get custom description or product coupon description.
                  if ( $woocommerce_gift_coupon_info_paragraph_type &gt; 0 ) {
                      $description_coupon = empty( $data_coupon-&gt;post_excerpt ) ? wp_trim_words( $data_coupon-&gt;post_content, 55, '...' ) : $data_coupon-&gt;post_excerpt;
                  }
              }
          }
      } else {
          if ( empty( $title_coupon ) ) {
              $title_coupon = 'Lorem ipsum dolor sit amet';
          }
          if ( empty( $description_coupon ) ) {
              $description_coupon = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
          }
      }
  
      $email  = '&lt;!DOCTYPE html&gt;
      &lt;html ' . get_language_attributes() . '&gt;
          &lt;head&gt;
              &lt;meta http-equiv="Content-Type" content="text/html; charset=' . get_bloginfo( 'charset' ) . '" /&gt;
              &lt;title&gt;' . get_bloginfo( 'name', 'display' ) . '&lt;/title&gt;';
      $email .= woocommerce_gift_coupon_generate_email_styles();
      $email .= '&lt;/head&gt;
          &lt;body bgcolor="#f5f5f5" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"&gt;
              &lt;div class="page-break-inside: avoid"&gt;
                  &lt;table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" bgcolor="#f5f5f5"&gt;
                      &lt;tr&gt;
                          &lt;td align="center" valign="top"&gt;
                              &lt;table bgcolor="#f5f5f5" border="0" cellpadding="0" cellspacing="0" width="595"&gt;
                                  &lt;tr&gt;
                                      &lt;td align="center" valign="top"&gt;
                                          &lt;table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#fff"&gt;
                                              &lt;tr&gt;
                                                  &lt;td align="center" valign="top"&gt;
                                                      &lt;table border="0" cellpadding="0" cellspacing="0" width="595"&gt;
                                                          &lt;tr&gt;
                                                              &lt;td align="center" valign="top" width="595"&gt;
                                                                  &lt;table border="0" cellpadding="20" cellspacing="0" width="100%"&gt;
                                                                      &lt;tr&gt;
                                                                          &lt;td align="center" valign="top" bgcolor="' . $woocommerce_gift_coupon_bg_color_header . '"&gt;';
          if ( $woocommerce_gift_coupon_show_logo &gt; 0 &amp;&amp; !empty( $woocommerce_gift_coupon_logo_base64 ) ) {
                                                                              $email .= '&lt;img src="' . $woocommerce_gift_coupon_logo_base64 . '" width="190" /&gt;';
          }
                                                                          $email .= '
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                      &lt;tr&gt;
                                                                          &lt;td align="center" valign="top" bgcolor="' . $woocommerce_gift_coupon_bg_color_title . '"&gt;
                                                                              &lt;h1&gt;' . $title_coupon . '&lt;/h1&gt;';
          if ( $woocommerce_gift_coupon_hide_amount &lt; 1 ) {
                                                                                  $email .= '&lt;h2&gt;' . $data['price'] . '&lt;/h2&gt;';
          }
                                                                          $email .= '&lt;/td&gt;
                                                                      &lt;/tr&gt;           
                                                                      &lt;tr&gt;
                                                                          &lt;td align="center" valign="top" bgcolor="#ccc"&gt;
                                                                              &lt;h3&gt;' . esc_html__( 'Code', WOOCOMMERCE_GIFT_COUPON_TEXT_DOMAIN ) . ': ' . $data['code'] . '&lt;/h3&gt;
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                      &lt;tr&gt;
                                                                          &lt;td align="left" valign="middle"&gt;
                                                                              ' . $description_coupon . '
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/table&gt;
                                                              &lt;/td&gt;
                                                          &lt;/tr&gt;
                                                      &lt;/table&gt;
                                                  &lt;/td&gt;
                                              &lt;/tr&gt;
                                          &lt;/table&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;table bgcolor="' . $woocommerce_gift_coupon_bg_color_footer . '" border="0" cellpadding="0" cellspacing="0" width="595"&gt;                        
                                  &lt;tr&gt;
                                      &lt;td align="center" valign="top"&gt;      
                                          &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
                                              &lt;tr&gt;
                                                  &lt;td align="center" valign="top"&gt;
                                                      &lt;table border="0" cellpadding="0" cellspacing="0" width="595"&gt;
                                                          &lt;tr&gt;
                                                              &lt;td align="center" valign="top" width="595"&gt;
                                                                  &lt;table border="0" cellpadding="20" cellspacing="0" width="100%"&gt;
                                                                      &lt;tr&gt;
                                                                          &lt;td align="center" valign="top"&gt;
                                                                              ' . $woocommerce_gift_coupon_info_footer . '
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/table&gt;
                                                              &lt;/td&gt;
                                                          &lt;/tr&gt;
                                                      &lt;/table&gt;
                                                  &lt;/td&gt;   
                                              &lt;/tr&gt;                             
                                          &lt;/table&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/table&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/div&gt;
          &lt;/body&gt;
      &lt;/html&gt;';
      return $email;
  }
  
  /**
   * Add inline styles to PDF template.
   */
  function woocommerce_gift_coupon_generate_email_styles() {
      $styles = '
      &lt;style type="text/css"&gt;
          html { 
              background-color:#fff; 
              margin:0; 
              padding:0; 
          }
          body{
              height:100%!important; 
              margin:0; 
              padding:0; 
              width:100%!important;
              font-family:DejaVu Sans, Helvetica;
          }
          table{
              border-collapse:collapse;
          }
          table[id=bodyTable] {
              table-layout: fixed;
              max-width:100%!important;
              width: 100%!important;
              min-width: 100%!important;
              margin:40px 0;color:#7A7A7A;
              font-weight:normal;
          }
          table img, 
          table a img{
              border:0; 
              outline:none;
              text-decoration:none;
              height:auto;
              line-height:100%;
          }
          table a{
              text-decoration:none!important;
              border-bottom:1px solid #ff5a34;
          }
          table a:hover{
              text-decoration:none!important;
              border-bottom:1px solid #1A242E;
          }
          table h1,
          table h2,
          table h3{
              color:#fff;
              font-weight:bold;
              line-height:100%;
              text-align:center;
              letter-spacing:normal;
              font-style: normal;
              margin:0!important;
              padding:0!important;
          }
          table h1 {
              text-transform:uppercase;
              display: block;
              font-family:DejaVu Sans, Helvetica;
              font-size: 56px;
              line-height: 1.385em;
              font-weight: normal;
          }
          table h2 {
              text-transform:uppercase;
              font-size: 86px;
              display: block;
          }
          table h3 {
              color:#252525;
              line-height:100%; 
              font-size:24px;
          }
      &lt;/style&gt;';
      return $styles;
  }</code></pre>
  </div>
  </div>
  </p>
  <p>How can I display the current date for example below the coupon code or in the top left/right corner?
  <a href="https://i.stack.imgur.com/eCMpO.png" rel="nofollow noreferrer">Here is a picture of the generated PDF Coupon as Example</a></p>
  <p>Many thanks in advance for your support!</p>