MomentJS - Czas trwania
MomentJS zapewnia ważną funkcję zwaną durations, która obsługuje długość czasu dla danych jednostek. W tym rozdziale dowiesz się tego szczegółowo.
Metody dostępne z czasem trwania
Poniższa tabela przedstawia dostępne metody z czasem trwania dla różnych jednostek, które mają być używane z czasem trwania -
| metoda | Składnia |
|---|---|
| Tworzenie | moment.duration (liczba, ciąg); moment.duration (Number); moment.duration (Object); moment.duration (String); |
| Klonuj | moment.duration (). clone (); |
| Humanizować | moment.duration (). humanize (); |
| Milisekundy | moment.duration (). milliseconds (); moment.duration (). asMilliseconds (); |
| sekundy | moment.duration (). sekundy (); moment.duration (). asSeconds (); |
| Minuty | moment.duration (). minutes (); moment.duration (). asMinutes (); |
| godziny | moment.duration (). hours (); moment.duration (). asHours (); |
| Dni | moment.duration (). dni (); moment.duration (). asDays (); |
| Tygodnie | moment.duration (). tygodnie (); moment.duration (). asWeeks (); |
| Miesięcy | moment.duration (). miesiące (); moment.duration (). asMonths (); |
| Years | moment.duration (). lata (); moment.duration (). asYears (); |
| Dodaj czas | moment.duration (). add (liczba, ciąg); moment.duration (). add (Number); moment.duration (). add (Czas trwania); moment.duration (). add (Object); |
| Odejmij czas | moment.duration (). subtract (liczba, ciąg); moment.duration (). subtract (Number); moment.duration (). subtract (czas trwania); moment.duration (). subtract (Object); |
| Używanie Duration with Diff | var duration = moment.duration (x.diff (y)) |
| Jako jednostka czasu | moment.duration (). as (String); |
| Uzyskaj jednostkę czasu | duration.get ('hours'); duration.get ('minuty'); duration.get ('sekundy'); duration.get ('milisekundy'); |
| Jako JSON | moment.duration (). toJSON (); |
| To czas trwania | moment.isDuration (obj); |
| Jako ciąg ISO 8601 | moment.duration (). toISOString (); |
| Widownia | moment.duration (). locale (); moment.duration (). locale (String); |