preprocesa theme

como envie la fecha formateada al twig

use DrupalCoreDatetimeDrupalDateTime;

 

function lucky_theme_preprocess_commerce_product(&$variables) {

// Get the commerce product.

$product = $variables[elements][#commerce_product];

// Pass the price.

$precio = explode(‘ ‘,$product->variations->entity->getPrice());

$valor = number_format($precio[0], 2, ., );

$variables[price] = S/. .$valor;

#Fecha fin

$date = new DrupalDateTime($product->field_fecha_fin_publicacion->value, UTC);

$date->setTimezone(new DateTimeZone(America/Lima));

$fecha = $date->format(Y-m-dTH:i:s);

 

$variables[fecha_fin] = $fecha;

 

}