strtotime examples

Examples for strtotimeHere are some example strtotime syntaxes for PHP. Leave a comment with an example if you like.

strtotime('today 14:00');
strtotime('tomorrow 14:00');
strtotime('tomorrow 2:00pm');
strtotime('now +2 hours');
strtotime('now +2 minutes');
strtotime('now +24 hours');
strtotime('now +12 hours');
strtotime('today +3 days');
strtotime('now +5 days');

A Quick reference of accepted input:

Numeric steps (+1, -1 ...)
Numeric date/time (Y-m-d, H:i:s)
Ordinal names / numbers [first - twelfth = 1 - 12] *
Special ordinal name / numbers (last = -1, this = 0, next = 1)
Special words (tomorrow, yesterday, ago, fortnight, now, today,
  day, week, month, year, hour, minute, min, second, sec) **
Days / months [sunday - saterday, sun - sat, January - December, Jan - Dec]
Timezones (TZ="...")

* second is reserved for seconds in time notation, therefore is not allowed here

** plurals are also allowed by adding an ‘s’

via php manual

Related Posts:

  • No Related Posts
This entry was posted in Tech Tips, Web Development and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *