Display of the 'time variable' ...gustspeedmin_time

all about Meteohub on the new Raspberry PI platform

Moderator: Mattk

Post Reply
joachimF
Junior Boarder
Junior Boarder
Posts: 34
Joined: Sun Jun 29, 2014 11:09 pm
Location: 83570 Carces France
Contact:

Display of the 'time variable' ...gustspeedmin_time

Post by joachimF »

Hallo,

the time format is : 20140816003138
very bad (for reading)
Is there a better solution?
Best Regards
Joachim

http://www.puttkammer.de
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 604
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: Display of the 'time variable' ...gustspeedmin_time

Post by wvdkuil »

joachimF wrote:Hallo,

the time format is : 20140816003138
very bad (for reading)
Is there a better solution?
These data fields are all the same, for all weatherdata fields, for the highs and lows, time periods as today, last month and so on.
They are human readable and are easy to process in php. What could one want more?
After much experience with all kind of weatherprograms in the past three years, I still prefer the meteohub data format, although with hindsight an extra T between the data and the time part whould have been a more standardized form 20140816T003138 to process.

I attached a small portion of my trends page with Meteohub data and times. now in human readable form.

Please explain a little more, what exactly is it that you want to be different?
Always ready to learn something new.

Wim
Attachments
datetimes.jpg
datetimes.jpg (90.6 KiB) Viewed 6313 times
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re: Display of the 'time variable' ...gustspeedmin_time

Post by admin »

Chapter 3.4 in the Meteohub manual explains how to decompose strings like that into a representation you like more. Please have a closer look at the "#" operator.
joachimF
Junior Boarder
Junior Boarder
Posts: 34
Joined: Sun Jun 29, 2014 11:09 pm
Location: 83570 Carces France
Contact:

Re: Display of the 'time variable' [solved]

Post by joachimF »

admin wrote:Please have a closer look at the "#" operator.
there I found the solution :)

code
um [day1_th0_tempmax_time#IJ]:[day1_th0_tempmax_time#KL]
result
um 14:35
Best Regards
Joachim

http://www.puttkammer.de
joachimF
Junior Boarder
Junior Boarder
Posts: 34
Joined: Sun Jun 29, 2014 11:09 pm
Location: 83570 Carces France
Contact:

Re: Display of the 'time variable' ...gustspeedmin_time

Post by joachimF »

wvdkuil wrote:are easy to process in php.
Bonsoir Wim,

I found a solution but I am also interested in a php solution. There is a HTML table in the MH Template

<table >
<tr>
<td class="links">Temp MAX heute<span class="klein_links">
um [day1_th0_tempmax_time#IJ]:[day1_th0_tempmax_time#KL]</span></td>
<td class="rechts">[day1_th0_tempmax_c] &deg;C</td>
</tr>

and MH uploaded this template and on my site you see this

Temp MAX heute um 14:51 28.7 °C

Please tell me explicit your way for display the date.
Best Regards
Joachim

http://www.puttkammer.de
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 604
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: Display of the 'time variable' ...gustspeedmin_time

Post by wvdkuil »

joachimF wrote:
wvdkuil wrote:are easy to process in php.
Bonsoir Wim,

I found a solution but I am also interested in a php solution. There is a HTML table in the MH Template

<table >
<tr>
<td class="links">Temp MAX heute<span class="klein_links">
um [day1_th0_tempmax_time#IJ]:[day1_th0_tempmax_time#KL]</span></td>
<td class="rechts">[day1_th0_tempmax_c] &deg;C</td>
</tr>

and MH uploaded this template and on my site you see this

Temp MAX heute um 14:51 28.7 °C

Please tell me explicit your way for display the date.
The normal way of working in PHP is to use the date function. It accepts a unix-date which is a 32 bit integer. The two functions in the examples, take a standard format string (example: 'd-m-Y') and a Meteohub datetime string as input. The resulting string is than returned as if a normal PHP date function was called. For long dates such as 'Freitag, 14 November 2014' another PHP function is used to translate the default english day and month names. Examples:

Code: Select all

This datetime will be used = 20141114150300

formatted date for 'd-m-Y H:i' = 14-11-2014 15:03

formatted date for 'H:i' = 15:03

formatted date for 'H' = 15

formatted date for 'd-m-Y' = 14-11-2014

formatted date for 'd-m' = 14-11



For date strings with day or month names we use a different function 

formatted date for '%A, %d %B %Y' = Friday, 14 November 2014

and for 'de_DE' the same function call returns = Freitag, 14 November 2014
So in your case it is only one date-time function, but it could be used in that place by replacing

Code: Select all

      um [day1_th0_tempmax_time#IJ]:[day1_th0_tempmax_time#KL]</span></td>
with

Code: Select all

      um <?php echo my_date( 'H:i', '[day1_th0_tempmax_time]'); ?></span></td>
or even better

Code: Select all

      um <?php echo my_date( $timeOnlyFormat, '[day1_th0_tempmax_time]'); ?></span></td>
The extension of the uploaded file would have to be .php
The definitions (such as $timeOnlyFormat) and the functions should either be included by a PHP include function or by adding it at the start of the .html in your Meteohub graphs folder.

It looks like far more work, and it is if it is only one date time field. But weather websites tend to grow, so it is easier to have all general functions for all pages in one script and use those standard functions and standard formats over and over again.

Wim
joachimF
Junior Boarder
Junior Boarder
Posts: 34
Joined: Sun Jun 29, 2014 11:09 pm
Location: 83570 Carces France
Contact:

Re: Display of the 'time variable' ...gustspeedmin_time

Post by joachimF »

Hi Wim,

many thanks for your explanation of the date function. I have tested it and it works, but i notice different times with php solution and the # operator :
Temperature 29.3 °C
um 20140818132809 - day1_th0_tempmax_time
um 13:28 - day1_th0_tempmax_time#IJ:........
um 00:33 - php ( 'H:i', '20140818132809')
Best Regards
Joachim

http://www.puttkammer.de
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 604
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: Display of the 'time variable' ...gustspeedmin_time

Post by wvdkuil »

joachimF wrote:Hi Wim,

many thanks for your explanation of the date function. I have tested it and it works, but i notice different times with php solution and the # operator :
Temperature 29.3 °C
um 20140818132809 - day1_th0_tempmax_time
um 13:28 - day1_th0_tempmax_time#IJ:........
um 00:33 - php ( 'H:i', '20140818132809')
The date function only works with an integer-value of an existing date as input.
you are feeding it a string date which is definitly not the integer value.
Take a look at the functions I included.
IN the function

Code: Select all

	$date 	= strtotime(substr($mhdate,0,8).'T'.substr($mhdate,8,6));
step 1 is add an T in the middle of the MH string: 20140818132809 becomes '20140818T132809 by the (substr($mhdate,0,8).'T'.substr($mhdate,8,6) part to make the string a date-string the strtotime function understands.
step 2 is convert that to an integer which is done by $date = strtotime( ) the rest of the first line;
step 3 is to let the $string = date($format,$date); date function generate an date in the format you want = date('format i want' , integerdate);

Hopes this clarifies, but again if it is only for a few dates, you should use the # ad the MH tag.

Wim
joachimF
Junior Boarder
Junior Boarder
Posts: 34
Joined: Sun Jun 29, 2014 11:09 pm
Location: 83570 Carces France
Contact:

Re: Display of the 'time variable' [solved php]

Post by joachimF »

wvdkuil wrote:Hopes this clarifies
Yes it is. Now I have the time with php :D .
I use the # , but now I understand 'php time' and this is usefull, when I make a new MH website.
Best Regards
Joachim

http://www.puttkammer.de
Post Reply