Jump to content

strtotime help with better syntax


jester626

Recommended Posts

I am playing around with strtotime and I have managed to come up with a sequence of code that works ok. What I am wanting to know from the community is if there is a better way to 'code' this an still achieve the same end result.

Here is what I am currently using:

<?PHP

$math58 = "58"*"86400";

$timestampmain = strtotime("12 October 2006");
$timestampmath = "$timestampmain" + "$math58";
echo date("m-d-Y",$timestampmath);
?>

Thank in Advance

Jess
Link to comment
https://forums.phpfreaks.com/topic/29219-strtotime-help-with-better-syntax/
Share on other sites

First you don't need all those double quotes, especially when you do math.

It looks like you want to get the date 58 days from the original date. You can do that within strtotime() itself.

[code]<?php
echo date('m-d-Y',strtotime("12 October 2006 + 58 days"));
?>[/code]

Ken

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.