Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created August 18, 2026 21:26
Show Gist options
  • Select an option

  • Save rickalday/3a6b52fc1aed275410fb5eb6d08a000c to your computer and use it in GitHub Desktop.

Select an option

Save rickalday/3a6b52fc1aed275410fb5eb6d08a000c to your computer and use it in GitHub Desktop.
GiveWP time email tag
<?php
function give_time_email_tag( $email_tags ) {
// Adds an email tag called {time} to output the donation time.
$email_tags[] = array(
'tag' => 'time', // The tag name.
'desc' => __( 'This outputs the donation time', 'give' ), // For admins.
'func' => 'render_time_email_tag', // Callback to function below.
'context' => 'donation',
);
return $email_tags;
}
add_filter( 'give_email_tags', 'give_time_email_tag', 999, 1 );
function render_time_email_tag( $tag_args ) {
$date = get_post_field( 'post_date', $tag_args['payment_id'] );
if ( empty( $date ) ) {
return '';
}
try {
$dateTime = new DateTime( $date );
// Change the format as needed. Output: 15:31:00
$output = $dateTime->format( 'H:i:s' );
} catch ( Exception $e ) {
$output = '';
}
return apply_filters( 'give_email_tag_give_time', $output, $tag_args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment