IntlCalendar::fieldDifference

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)

IntlCalendar::fieldDifferenceCalculate difference between given time and this objectʼs time

Beschreibung

Objektorientierter Stil

public IntlCalendar::fieldDifference(float $timestamp, int $field): int|false

Prozeduraler Stil

intlcal_field_difference(IntlCalendar $calendar, float $timestamp, int $field): int|false

Return the difference between the given time and the time this object is set to, with respect to the quantity specified the field parameter.

This method is meant to be called successively, first with the most significant field of interest down to the least significant field. To this end, as a side effect, this calendarʼs value for the field specified is advanced by the amount returned.

Parameter-Liste

calendar

Eine IntlCalendar-Instanz.

timestamp

The time against which to compare the quantity represented by the field. For the result to be positive, the time given for this parameter must be ahead of the time of the object the method is being invoked on.

field

The field that represents the quantity being compared.

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Rückgabewerte

Returns a (signed) difference of time in the unit associated with the specified fieldBei einem Fehler wird false zurückgegeben..

Beispiele

Beispiel #1 IntlCalendar::fieldDifference()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''fr_FR');

$cal1 IntlCalendar::fromDateTime('2012-02-29 09:00:11');
$cal2 IntlCalendar::fromDateTime('2013-03-01 09:19:29');
$time $cal2->getTime();

echo 
"Time before: "IntlDateFormatter::formatObject($cal1), "\n";

printf(
    
"The difference in time is %d year(s), %d month(s), "
  
"%d day(s), %d hour(s) and %d minute(s)\n",
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_YEAR),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_MONTH),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_DAY_OF_MONTH),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_HOUR_OF_DAY),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_MINUTE)
);

//now it was advanced to the target time, exception for the seconds,
//for which we did not measure the difference
echo "Time after: "IntlDateFormatter::formatObject($cal1), "\n";

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Time before: 29 févr. 2012 09:00:11
The difference in time is 1 year(s), 0 month(s), 1 day(s), 0 hour(s) and 19 minute(s)
Time after: 1 mars 2013 09:19:11

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

"How to warm cold entrance?"

What are some effective strategies for addressing the significant heat loss occurring in the entrance hall, which is noticeably the coldest area o ...

Geschrieben von NeerMohan am 01.05.2024 06:49:27
Forum: Fragen/Vorschläge zum Forum
Berechnungen durchführen

Hallo liebe Forenmitglieder, meine erste frage ist zum Aufbau meiner kleinen Berechnungswebseite, nichts kommerzielles, soll nur eine Anwendung f ...

Geschrieben von matze511 am 21.04.2024 21:42:37
Forum: PHP Developer Forum
Professioneller Webentwickler & Webdesigner

Of course, here is the translation: Hello, Thank you for your interest in the long-term project. Your extensive skills and experience in web dev ...

Geschrieben von Athelstan am 15.04.2024 09:25:39
Forum: Jobgesuche
Wir stellen unsere SEO-Agentur vor

Hallo In der heutigen digitalen Welt war es für Unternehmen noch nie so einfach, ihre Reichweite weltweit zu vergrößern. Wenn Sie außerhalb I ...

Geschrieben von thomasmuller am 14.04.2024 07:18:33
Forum: User stellen sich vor