Template:Is now
0
Usage
This template is intended to be used by other templates. It returns a "1" if the current time, as interpreted by {{#time: {{{format string|U}}} }} exactly matches any of the supplied times in the parameters |at1=, |at2=, and so on. Otherwise it returns a "0".
This is useful for recurring events, such as holidays, hours of the day, etc.
- Parameters
|format string=UFormat string to pass to {{#time:}}.|at1=,|at2=, etc. - strings to match|debug=- If set, then|format string=is printed. For debugging.
- Common format string parameter values. See mw:Help:Extension:ParserFunctions#.23time for further information.
-
|format string=M- 2-digit month of year. Returns 01 during January|format string=d- 2-digit day of month. Returns 01 on the 1st day of the month.|format string=w- Day of week. Returns 0 on Sunday|format string=M-d- 2-digit month, hyphen, 2-digit day. Returns 01-01 on January 1.|format string=xmn- Month as a number (Islamic calendar). Returns 1 during Muharram.|format string=xjn- Month as number (Hebrew calendar). Returns 1 during Nisan.|format string=H- Hour of the day (UTC).|format string=Defaults to U, which is "seconds since January 1 1970 00:00:00 UTC." This default is deliberately not useful to discourage the use of this template without specifying a format string.
- Recommended uses
- Displaying messages that only appear on certain, possibly non-consecutive days of the week, month, or year.
- Displaying messages that only appear during certain, possibly non-consecutive hours of the day.
- Demonstration (purge this page to update the result)
- Display whether it is the weekend (Saturday or Sunday) or a weekday (Monday through Friday) in the United States:
- {{#ifeq: {{Is now|format string=w|at1=0|at2=7}}|1|Enjoy the weekend|Another day, another dollar.}}
- yields
- Another day, another dollar.
- Limitations
- The "switch" from 0 to 1 happens only when the page this template is used on is updated or purged. If a page includes a template which calls this template, it is the page the reader sees, not the template which calls this template, which must be purged or updated.
- There is a hard-coded limit of 31
|atN=parameters, but this can be extended at any time.
- See also
- {{Age switch}}
- {{Compare dates}}
- {{If this academic year}}
- {{If this semester}}
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.