<?php
/**
 * Template part for displaying page content in page.php.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Flossy
 */
 
 
$post_date = get_the_date('Y-m-d'); // You can change the format as needed
// Convert the date to a DateTime object for more flexibility
$date = new DateTime($post_date);

// Break down the date into its components
$year = $date->format('Y');
$month = $date->format('m');
$day = $date->format('d');
?>
<div class="home-blog">
	<div class="blog-img tilt1">
		<?php if ( has_post_thumbnail() ) { ?>
			<?php the_post_thumbnail('medium'); ?>
		<?php } ?>
		
		<a href="<?php echo esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))); ?>" class="blog-img-calendar">
			<div class="calendar-date"><?php echo esc_html($day); ?></div>
			<div class="calendar-month"><?php echo esc_html($month); ?>, <?php echo esc_html($year); ?></div>
		</a>
		<?php if ( !is_single() ) { ?>
		<div class="hover-links">
			<a href="<?php echo esc_url(get_the_permalink()); ?>" class="blog-search-icon">
				<i class="fa fa-search"></i>
			</a>
		</div>
		<?php } ?>
	</div>
	
	<div class="blog-body">
	<?php     
		if ( is_single() ) :
		
		the_title('<h5 class="titles-16">', '</h5>' );
		
		else:
		
		the_title( sprintf( '<h5 class="titles-16"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h5>' );
		
		endif; 
	?> 
	<?php 
		the_content( 
				sprintf( 
					__( 'Read Blog', 'flossy' ), 
					'<span class="screen-reader-text">  '.esc_html(get_the_title()).'</span>' 
				) 
			);
	?>
	</div>
	<div class="blog-footer">
		<div class="meta-area">
			<?php  the_tags('<div class="meta-box"><div class="meta-icon"><i class="fa fa-folder-open"></i></div> <p class="meta-text"> ', ', ', '</p></div>'); ?>
		</div>
	</div>
</div>