PHP date from today to 4 months

Simon Fabb

Does anyone know why this keeps on showing the date 01-05-70?

$effectiveDate = strtotime("+4 months", strtotime($effectiveDate)); // returns timestamp
echo date('d-m-y',$effectiveDate); // formatted version

I want it to print today's date + 4 months.

John Conde

In your code $effectiveDate contains an invalid date. So strtotime() returns the unix epoch Jan 1, 1970.

But you shouldn't need that variable at all if all you want is the date four months from now.

echo date('d-m-y',strtotime('+4 months'));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Subtract days, months, years from a date in JavaScript

From Dev

Subtracting days, months or years from date using php

From Dev

In Rails 4 How can I display info from a database based on today's date?

From Dev

Python: Find date beginning two months prior to today AND start on a Monday

From Dev

Why does PHP date('m', strtotime('-1 months')) not work correctly for today? 07/31

From Dev

PHP Carbon get toDay date by formatting date

From Dev

How to subtract months from date in HIVE

From Dev

how can i run the loop from start date to end date for every 3 months in php

From Dev

Apply function to get months from today's date

From Dev

Find if date is older than 2 months in PHP

From Dev

PHP MYSQL Return last 3 months from a date from the DB - Mysql Query

From Dev

Subtract months from a given date in bash

From Dev

Get today's date in PHP?

From Dev

How to calculate 2 months from today using php date

From Dev

Set a variable date to six months prior to today

From Dev

Compare Two Dates and If Less than TODAY Add Date till TODAY and Add 6 Months to it

From Dev

Calculate previous and next months from date string

From Dev

How to subtract months from date in HIVE

From Dev

how can i run the loop from start date to end date for every 3 months in php

From Dev

Get records where today is 6 months after date

From Dev

Find if date is older than 2 months in PHP

From Dev

Get the next x months from today's date

From Dev

PHP date within 6 months

From Dev

Grouping months from a date column and adding quantities for all months

From Dev

Php add calendar months to a date

From Dev

SQL Fixed Date from Previous Months

From Dev

Compare "today" date with input date from form

From Dev

PHP- get the last 6 months from the current date

From Dev

Check if Date is 2 months prior to today's date

Related Related

  1. 1

    Subtract days, months, years from a date in JavaScript

  2. 2

    Subtracting days, months or years from date using php

  3. 3

    In Rails 4 How can I display info from a database based on today's date?

  4. 4

    Python: Find date beginning two months prior to today AND start on a Monday

  5. 5

    Why does PHP date('m', strtotime('-1 months')) not work correctly for today? 07/31

  6. 6

    PHP Carbon get toDay date by formatting date

  7. 7

    How to subtract months from date in HIVE

  8. 8

    how can i run the loop from start date to end date for every 3 months in php

  9. 9

    Apply function to get months from today's date

  10. 10

    Find if date is older than 2 months in PHP

  11. 11

    PHP MYSQL Return last 3 months from a date from the DB - Mysql Query

  12. 12

    Subtract months from a given date in bash

  13. 13

    Get today's date in PHP?

  14. 14

    How to calculate 2 months from today using php date

  15. 15

    Set a variable date to six months prior to today

  16. 16

    Compare Two Dates and If Less than TODAY Add Date till TODAY and Add 6 Months to it

  17. 17

    Calculate previous and next months from date string

  18. 18

    How to subtract months from date in HIVE

  19. 19

    how can i run the loop from start date to end date for every 3 months in php

  20. 20

    Get records where today is 6 months after date

  21. 21

    Find if date is older than 2 months in PHP

  22. 22

    Get the next x months from today's date

  23. 23

    PHP date within 6 months

  24. 24

    Grouping months from a date column and adding quantities for all months

  25. 25

    Php add calendar months to a date

  26. 26

    SQL Fixed Date from Previous Months

  27. 27

    Compare "today" date with input date from form

  28. 28

    PHP- get the last 6 months from the current date

  29. 29

    Check if Date is 2 months prior to today's date

HotTag

Archive