I have a rather interesting problem... I am still really new to PHP and I have some C++ background.
I am working on a project where we take the day as a unix time code and either decrement or increment it depending on the outcome of a test
I foolishly thought that it would work to just use:
$variableName++ ( or $variableName--) but alas it just seems to ignore the operator.
Can anybody help on this?
Thanks,
Incrementing or Decrementing a variable with unix timecode
Moderator: General Moderators
-
irishmike2004
- Forum Contributor
- Posts: 119
- Joined: Mon Nov 15, 2004 3:54 pm
- Location: Lawrence, Kansas
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
what function did you use to get the unix timestamp? If it's from outside php, can you post an example of one?
If it's a ULONG, then ++ and -- will work, but will only add or subtract 1 second of time....
If it looks like 200501121506 then it's not a time stamp, but a printed evaluation of one. If it's that, I can post a regular expression to extract the time information and convert it back to timecode.
If it's a ULONG, then ++ and -- will work, but will only add or subtract 1 second of time....
If it looks like 200501121506 then it's not a time stamp, but a printed evaluation of one. If it's that, I can post a regular expression to extract the time information and convert it back to timecode.
-
irishmike2004
- Forum Contributor
- Posts: 119
- Joined: Mon Nov 15, 2004 3:54 pm
- Location: Lawrence, Kansas
we actually need to increment a day or take away a day
the way we are getting our timestamp is by:
I need to for example if today is 12 January 2005 and we convert that into a timecode via strtotime() and then we want to increase that to 13 of January
I think I figured it out... thanks.
Code: Select all
$variable = time();I think I figured it out... thanks.
Hi
I don't know how you did it, but here is the shortest way to do what you wanted!
You can change the output format in the date() function to how you want it displayed!
printf
I don't know how you did it, but here is the shortest way to do what you wanted!
Code: Select all
<?
$date = '12 January 2005';
echo date ( 'd F Y', strtotime ( $date . "+ 1 day" ) );
?>printf