Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.php > #4126
| From | Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) |
|---|---|
| Newsgroups | de.comp.lang.php |
| Subject | Re: Schichtplan anhand Stichtag mit php |
| Date | 2017-06-07 20:31 +0000 |
| Message-ID | <bt59386223i7fben3e8%sfroehli@Froehlich.Priv.at> (permalink) |
| References | <oh9lk6$ek4$2@news.freedyn.net> <oh9m1m$g9j$1@news.freedyn.net> |
On Wed, 07 Jun 2017 21:17:24 Timo wrote:
> Am 07.06.2017 um 21:10 schrieb Timo:
> > ich bin aktuell am basteln eines Schichtplans in php.
>
> > Am Ende soll er mir die zuständige Schicht eines übergebenen Tages
> > zurückgeben.
> >
> > Schichtmüster beginnend 05.09.2017:
> > VA,VA,F,F,S,S,S,N,N,VA,VA,F,F,F,S,S,N,N,VA,VA,VA,F,F,S,S,N,N,N
> >
> > Git es in php eine einfache Möglichkeit?
#v+
<?php
$shifts = [
'VA', 'VA', 'F', 'F', 'S', 'S', 'S',
'N', 'N', 'VA', 'VA', 'F', 'F', 'F',
'S', 'S', 'N', 'N', 'VA', 'VA', 'VA',
'F', 'F', 'S', 'S', 'N', 'N', 'N'
];
$begin = new DateTime('2017-09-05');
$test = new DateTime($argv[1]);
$days = $test->diff($begin)->days;
echo $shifts[$days % count($shifts)] . "\n";
?>
#v-
> > Sodass, wenn ich dem Script z.B. das Datum 22.09.2017 übergebe, dass
> > ich dann den Wert "N" zurückerhalte?
| $ php shift.php 2017-09-05
| VA
| $ php shift.php 2017-09-22
| N
> Jedoch wird es kompliziert, wenn man dann ein Datum aus 2018 oder 2019
> abfragt, da das Script auch Wechseljahre berüchsichtigen muss.
Geht ganz automatisch.
Servus,
Stefan
--
http://kontaktinser.at/ - die kostenlose Kontaktboerse fuer Oesterreich
Offizieller Erstbesucher(TM) von mmeike
Wolke Nummer sieben zum verlieben. Mit Stefan. Ein rotes Vergnügen!
(Sloganizer)
Back to de.comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
Schichtplan anhand Stichtag mit php Timo <timo@intranet1.schaffert.info> - 2017-06-07 21:10 +0200
Re: Schichtplan anhand Stichtag mit php Timo <timo@intranet1.schaffert.info> - 2017-06-07 21:17 +0200
Re: Schichtplan anhand Stichtag mit php Sebastian Suchanek <sebastian.suchanek@gmx.de> - 2017-06-07 21:34 +0200
Re: Schichtplan anhand Stichtag mit php Timo <timo@intranet1.schaffert.info> - 2017-06-07 21:56 +0200
Re: Schichtplan anhand Stichtag mit php Christian Stadler <stadli@gmx.de> - 2017-06-07 21:46 +0200
Re: Schichtplan anhand Stichtag mit php Timo <timo@intranet1.schaffert.info> - 2017-06-07 22:01 +0200
Re: Schichtplan anhand Stichtag mit php Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2017-06-07 20:31 +0000
csiph-web