astronomy date formating [solved]

Hi every one and body,

Actualy my testtags.php file is returning astronomical dates under
the format $firstquarter = “17:03 UTC 13 mai 2016”;

How can I do, WITHOUT DISTURBING the date formats for all the rest,
to have them as:

‘d m Y H:m’

Thanks for the help.

Regards.

-= Guy =-

one problem is if I change it too much then scripts that use it will break

Thanks Brian for the answer,

You could if you wish add a second var $firstquarterxxxx with another format

and why not at the same time calculate local time thanks to lat lon already in the
settings of WD. Just a tought.

Regards.

-= Guy =-

You can reformat it in php but unfortunately the function to do it only works with the month in English so it would need to be done in two steps.

Have two strings, one with his language, one with ENG, then do match/replace and then strtotime to convert to timestamp and then output using date function in whatever format you want

Exactly! If the month was in English strtotime would do it directly :lol:

Thanks niko & Jachym,

You are both right and I am all eady working on that with a small .php script.

First have to replace french month by english month and do all what you guys say.

I have also to affect DST.

Lost of .php buisness… :slight_smile:

Thanks,

Regards.

-= Guy =-

If you have the time zone set in the script, then the DST will be taken care of.

Write it as a function so it’s easy to use for multiple dates :wink:

niko,

Why are my vars in the tesstags.php file with French month while everything
in WD is in english.

By the way, testtags.php retruns the First Quater Moon etc, dates as: 19:30 UTC 6 mai 2016

which I find a very weird date/time formatting. So the first thing to do is to delete the ‘UTC’ string.

Thanks again,

Regards.

= Guy =-

Regarding DST I use this small function.

function isdst() { $dststart = strtotime("Last Sunday March 2"); // In France DST begins last Sunday of March @ 02:00 $dstend = strtotime("Last Sunday October 3"); // In France DST ends last Sunday of October @ 03:00 $time = time(); if( $time > $dststart && $time < $dstend ) { $offset = 2; } // In France DST = GMT + 2 else { $offset = 1; } // In France non DST = GMT + 1 return $offset; }

This one is for France and works fine. DST may be adjusted in the $offset return var without forgetting
the two first line where dates of begining and end of DST must be set.

-= Guy =-

I think you are making it more complicated than it has to be, the WD date is telling you it is UTC so php can work with that directly. I would do something like this: (I don’t know if the date name is shortened or not, hard to tell with “mai” so the $franmo array is not complete.) And you’ll need to reverse the translation after the format conversion.

<?php
date_default_timezone_set('Europe/Paris');
$olddate =  "17:03 UTC 13 mai 2016";
$engmo = array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
$franmo = array("jan","fev","mar","apr","mai","jun","jul","aug","sep","oct","nov","dec");
$newdate = date("D M j G:i:s T Y",strtotime(str_ireplace($franmo, $engmo, $olddate)));
echo $olddate." = ".$newdate;
?>

Hi,

I solved my problem with a small non academic php script, but it works.
I remind that my testtags.php file comes out with French formated date/times.
So my solution is turned torwards French date. I can be accomodated to other languages.

[quote]
function getlocdate ($indate) { // Incoming UTC French date in wxastronomy it is $firstquarter, $fullmoon, $lastquarter and $nextnewmoon.
if(substr($indate, 11, 1) == ’ ') {$monthfr = substr($indate, 12, 3); // Let’s get three first carracters of French month
if ($monthfr == ‘jui’) {$monthfr = substr($indate, 12, 4);} // June & July in French begin both by jui so lest’s get four fist caracters
} else {$monthfr = substr($indate, 13, 3); if ($monthfr == ‘jui’) { $monthfr = substr($indate, 13, 4); } }

$monthlist = array(0 => ‘’, ‘january’ => ‘jan’, “february” => 'f

[quote author=meteo link=topic=62864.msg503604#msg503604 date=1463782171]PS: @ Niko, sorry but your $franmo = array(“jan”,“fev”,“mar”,“apr”,“mai”,“jun”,“jul”,“aug”,“sep”,“oct”,“nov”,“dec”); array is wrong and further more testtags.php for these date/month returnes ‘janvier’, 'f

Sorry Niko,

I did not remember and of course there was no offense intended.

I allways appreciate your helps as you, Brian and Jachym are the
only ones with enough knowledge to give a hand.

Thanks,

Regards.

-= Guy =-

None taken, glad you got a working solution :smiley: