Check the code below ( Tested and works fine). If you are having issues with incorrect time, see if the timezone is set correct. Based on your query I assume the timezone should be Kolkatta.
Goto Dashboard -> Settings -> General -> Timezone
function dispatch_message(){
$current_time = current_time('D | H');
$current_time = explode('|', $current_time );
$current_day = isset( $current_time[0] ) ? trim( $current_time[0] ) : false;
$current_hour = isset( $current_time[1] ) ? trim( $current_time[1] ) : false;
$message = '4-5 Working Days.';
if( in_array( $current_day, array( 'Fri', 'Sat', 'Sun' ) ) ){
//Weekend
$message = '3-5 Working Days from Monday.';
}else if( $current_hour <= "12"){
//Before 12pm IST
$message = '3-5 Working Days.';
}
?>
<div style="clear: both"></div>
<div style="margin-top: 10px;font-size: 17px;color: red;">
<b>Est Dispatch Date:</b> <?php echo $message; ?>
</div>
<br>
<?php
}
add_action( 'woocommerce_before_add_to_cart_button', 'dispatch_message' );
UPDATE
You can make changes to the above code inorder to hide the dispatched date for certain categories. Add the if condition as the first line of code as shown below and return inorder to skip the remaining part of function.
function dispatch_message(){
if ( is_product() && has_term( array( 'dress', 'clothing' ), 'product_cat' ) ){
return;
}
$current_time = current_time('D | H');
$current_time = explode('|', $current_time );
$current_day = isset( $current_time[0] ) ? trim( $current_time[0] ) : false;
$current_hour = isset( $current_time[1] ) ? trim( $current_time[1] ) : false;
$message = '4-5 Working Days.';
if( in_array( $current_day, array( 'Fri', 'Sat', 'Sun' ) ) ){
//Weekend
$message = '3-5 Working Days from Monday.';
}else if( $current_hour <= "12"){
//Before 12pm IST
$message = '3-5 Working Days.';
}
?>
<div style="clear: both"></div>
<div style="margin-top: 10px;font-size: 17px;color: red;">
<b>Est Dispatch Date:</b> <?php echo $message; ?>
</div>
<br>
<?php
}
add_action( 'woocommerce_before_add_to_cart_button', 'dispatch_message' );