Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

perl: wochentag aus datum?

Empfohlene Antworten

Veröffentlicht

moin leute,

weiß von euch einer wie ich aus einem datum (format ist egal) den wochentag bzw. die sekunden ab xx.xx.1970 ermitteln kann?

in php gibts da glaub ich so ne funktion (mktime) aber in perl find ich nichts.. :(

gruß

attheo

habs jetzt,

hier die lösung, falls es einen interessiert:


use Time::Local;



   ($d,$m,$y) = split /\./, $date;

   $m         = $m - 1;

   $y         = $y - 1900;

   $sec       = timelocal(00,00,00, $d, $m, $y);

   ($tmp, $tmp, $tmp, $tmp, $tmp, $tmp, $wday) = localtime($sec);


$wday enthält dann 0-6 für sonntag - samstag..

gruß

attheo

p.s. hier gibts nicht so viele perl programmierer, oder? ;)

Originally posted by attheo

p.s. hier gibts nicht so viele perl programmierer, oder? ;)

Wenn du das nächste mal dein Problem länger als eine Stunde bestehen lässt, antwortet dir vielleicht auch jemand. ;)

Gruß Jaraz

Hi,

probiers mal hiermit:

<Code>

($sek,$min,$std,$tag,$mon,$jahr) = gmtime(time);

$sek = &zweistellig ($sek);

$min = &zweistellig ($min);

$std = &zweistellig ($std);

$tag = &zweistellig ($tag);

$mon = &zweistellig (++$mon);

$jahr = $jahr + 1900;

$datum = ("$jahr$mon$tag");

sub zweistellig

{

if (length ($_[0]) < 2)

{

return "0".$_[0];

}

else

{

return $_[0];

}

}

</Code>

mfg korea1

hmm? versteh nicht ganz.. auf welche frage hast du geantwortet? :confused:

hi,

mit $datum bekommst du 20021211 => 11 is der tag den du wolltest, od?

das unterprogramm sub zweistellig sorgt dafür, dass du den tag auch zweistellig ausgegeben bekommst z.B. 03.

mfg

nee.. das kriegt man ja auch mit localtime(time) raus..

ich wollte aus z.B. 11.12.02 -> Mittwoch (oder ne zahl von 1-7) raushaben..

die lösung steht im 2en post..

gruß

attheo

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.