Jump to content

[SOLVED] making time not working??


shadiadiph

Recommended Posts

I have been trying to make some times maybe i am just too tired but i can't figure out why this is producing errors??

 

$todaysdate = date('Y-m-d');
$todaysdateintime = strtotime($todaysdate);

$1days = "$todaysdateintime - 86400";

$3days = "$todaysdateintime - 259200";

$7days = "$todaysdateintime - 604800";

$14days = "$todaysdateintime - 1209600";

$21days = "$todaysdateintime - 1814800";

$30days = "$todaysdateintime - 2592000";

$1day  = date('Y-m-d',$1days);
$3day  = date('Y-m-d',$3days);
$7day  = date('Y-m-d',$7days);
$14day = date('Y-m-d',$14days);
$21day = date('Y-m-d',$21days);
$30day = date('Y-m-d',$30days);

Link to comment
https://forums.phpfreaks.com/topic/154033-solved-making-time-not-working/
Share on other sites

lol I could of just read your script ::)

 

change this...

<?php
$1days = "$todaysdateintime - 86400";

$3days = "$todaysdateintime - 259200";

$7days = "$todaysdateintime - 604800";

$14days = "$todaysdateintime - 1209600";

$21days = "$todaysdateintime - 1814800";

$30days = "$todaysdateintime - 2592000";

to this...

<?php
$days1 = $todaysdateintime - 86400;

$days3 = $todaysdateintime - 259200;

$days7 = $todaysdateintime - 604800;

$days14 = $todaysdateintime - 1209600;

$days21 = $todaysdateintime - 1814800;

$days30 = $todaysdateintime - 2592000;

 

variables can't start with a number, and wrapping those double quotes " " around its value with the numbers on the end makes it think it is a string(text) instead of 2 numbers subtracting.

it was producing the same error on the same line

 

but this seems to work

 

$todaysdate = date('Y-m-d');
$todaysdateintime = strtotime($todaysdate);

$oneday = $todaysdateintime - 86400;

$threeday = $todaysdateintime - 259200;

$sevenday = $todaysdateintime - 604800;

$fourteenday = $todaysdateintime - 1209600;

$twentyoneday = $todaysdateintime - 1814800;

$thirtyday = $todaysdateintime - 2592000;

$onedays  = date('Y-m-d',$oneday);
$threedays  = date('Y-m-d',$threeday);
$sevendays  = date('Y-m-d',$sevenday);
$fourteendays = date('Y-m-d',$fourteenday);
$twentyonedays = date('Y-m-d',$twentyoneday);
$thirtydays = date('Y-m-d',$thirtyday);

 

thanks for the help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.