fazarcon

format date

Jun 22nd, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){
  2. if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'my-date' ) !== false ) {
  3. $timestamp = strtotime($content);
  4. $new_date = date("d-m-Y", $timestamp);
  5.  
  6. $my_date = sprintf(
  7. '<time datetime="%1$s">%2$s</time>',
  8. date('c', $timestamp),
  9. date('l F j, Y', $timestamp) );
  10. return $my_date;
  11. }
  12. return $content;
  13. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment