Hallo,
the time format is : 20140816003138
very bad (for reading)
Is there a better solution?
Display of the 'time variable' ...gustspeedmin_time
Moderator: Mattk
Re: Display of the 'time variable' ...gustspeedmin_time
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.joachimF wrote:Hallo,
the time format is : 20140816003138
very bad (for reading)
Is there a better solution?
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 (90.6 KiB) Viewed 6314 times
Re: Display of the 'time variable' ...gustspeedmin_time
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.
-
- Junior Boarder
- Posts: 34
- Joined: Sun Jun 29, 2014 11:09 pm
- Location: 83570 Carces France
- Contact:
Re: Display of the 'time variable' [solved]
there I found the solutionadmin wrote:Please have a closer look at the "#" operator.

code
um [day1_th0_tempmax_time#IJ]:[day1_th0_tempmax_time#KL]
result
um 14:35
-
- 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
Bonsoir Wim,wvdkuil wrote:are easy to process in php.
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] °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.
Re: Display of the 'time variable' ...gustspeedmin_time
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:joachimF wrote:Bonsoir Wim,wvdkuil wrote:are easy to process in php.
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] °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.
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
Code: Select all
um [day1_th0_tempmax_time#IJ]:[day1_th0_tempmax_time#KL]</span></td>
Code: Select all
um <?php echo my_date( 'H:i', '[day1_th0_tempmax_time]'); ?></span></td>
Code: Select all
um <?php echo my_date( $timeOnlyFormat, '[day1_th0_tempmax_time]'); ?></span></td>
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
-
- 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
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')
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')
Re: Display of the 'time variable' ...gustspeedmin_time
The date function only works with an integer-value of an existing date as input.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')
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 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
-
- 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]
Yes it is. Now I have the time with phpwvdkuil wrote:Hopes this clarifies

I use the # , but now I understand 'php time' and this is usefull, when I make a new MH website.