Hola buen dia, tengo un problema con los horarios del script, lo demás funciona perfecto, por favor les agradezco la ayuda :encouragement:
Así se ve mi script, cuando esta de noche (Aun no le cambio font, la imagen se la cambie).
Tengo el problema que no cambia de horario en el momento que debería, esta con Lima-Peru y quiero que funcione con Santiago-Chile, pero que cambie en el momento justo.
PD: Se podrá cambiar el texto Mostly Cloudy (Mayormente Nublado) dejarlo siempre en español, lo demás funciona super bien todo lo indica preciso.
Les dejo el code:
Gracias. :encouragement:
Así se ve mi script, cuando esta de noche (Aun no le cambio font, la imagen se la cambie).
Tengo el problema que no cambia de horario en el momento que debería, esta con Lima-Peru y quiero que funcione con Santiago-Chile, pero que cambie en el momento justo.
PD: Se podrá cambiar el texto Mostly Cloudy (Mayormente Nublado) dejarlo siempre en español, lo demás funciona super bien todo lo indica preciso.
Les dejo el code:
Insertar CODE, HTML o PHP:
<?php
require("simplepie.inc");
require("simplepie_yahoo_weather.inc");
$code = "28358234&u=c";
$path = "http://weather.yahooapis.com/forecastrss?w=";
$feed = new SimplePie();
$feed->set_feed_url($path.$code);
$feed->set_item_class('SimplePie_Item_YWeather');
$feed->init();
function time2minuts($time) {
$minuts = 0;
$atime = explode(" ", $time);
if (strtolower($atime[1]) == "pm") {
$minuts = 12*60;
}
$ttime = explode(":", $atime[0]);
$minuts = $minuts + (int)$ttime[0]*60 + (int)$ttime[1];
return $minuts;
}
$weather = $feed->get_item(0);
$fore = $weather->get_forecasts();
$unit = $weather->get_units_temp();
$ampm = "n";
$icon = $weather->get_condition_code();
$curday = 2*60 + time2minuts(date("g:i a"));
$iniday = time2minuts($weather->get_sunrise());
$endday = time2minuts($weather->get_sunset());
if ($curday > $iniday && $curday < $endday ) {
$ampm = "d";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Yahoo Weather</title>
<style type="text/css">
<!--
body {
font-family: "Trebuchet MS", Tahoma, Verdana;
font-size: 12px;
font-weight: normal;
color: #777777;
text-decoration: none;
background-color: #FFFFFF;
}
#weather {
width: 240px;
height: 120px;
}
#current {
width: 240px;
height: 120px;
text-align: right;
color: #FFFFFF;
font-weight: bold;
}
#current #temp {
font-size: 24px;
font-style: normal;
padding-top: 40px;
padding-right: 16px;
}
#current #fore {
padding-right: 16px;
font-size: 11px;
}
#current #city {
padding-right: 16px;
}
-->
</style>
</head>
<body>
<div id="weather" style="background:url('icon<?php echo $ampm; ?>.png') no-repeat 40px 40px;">
<div id="current">
<div id="temp"><?php echo $weather->get_temperature(); ?>°<?php echo $unit; ?></div>
<div id="fore"><?php echo $fore[0]->get_low()."°".$unit; ?> - <?php echo $fore[0]->get_high()."°".$unit; ?></div>
<div id="city"><?php echo $weather->get_city().", ".$weather->get_country(); ?></div>
</div>
<ul>
<li><strong>Condición:</strong> <?php echo $weather->get_condition(); ?></li>
<li><strong>Humedad:</strong> <?php echo $weather->get_humidity(); ?>%</li>
<li><strong>Amanecer:</strong> <?php echo $weather->get_sunrise(); ?></li>
<li><strong>Atardecer:</strong> <?php echo $weather->get_sunset(); ?></li>
</ul>
</div>
</body>
</html>
Gracias. :encouragement: