Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Negative Number In Strtotime


What does a negative number in strtotime mean? I looked in the manual, couldn't figure it out.

strtotime('-1 month')




View Complete Forum Thread with Replies

Related Forum Messages:
Strtotime() Not Subtracting Negative Numbers?
I'm having an issue with the strtotime function not doing math the way I was taught it works in school.......

I am using strtotime() to add and subtract times in my timezone application. The problem is when I go to subtract the offset from UTC strtotime() subtracts the ABSOLUTE VALUE of the offset insteat of the actual value.

ie:strtotime(now().'- -4 hours');should give me my current UTC as I am in the eastern time zone of North America and it is daylight savings time. However, it gives me the same result as:strtotime(now().'-4 hours');thus sending me somewhere off the west coast - time-zonally speaking. Code:

View Replies !
Number_format() Cannot Take In Negative Number
$myNumb = -123;
I am trying to do number_format($myNumb, 2) which I would expect to return -123.00, but it returns 0. How do I get around this?

View Replies !
Displaying A Message If A Number Goes Negative.
I'm trying to display a comment if my query comes up nagative, my result is displayed as a time (00:00:00 Format), I want it so that when my time goes negative (-01:00:00) it will display a comment, but when it is positive it will display the time. I already have the time displayed by using:

print $record['time_diff'];

But I'm not very clued up when it comes to if and else commands.

This is a section of my code that I can't get to work, Im sure you will see the problem straight away but I can't and have tried a few things.

$result = mysql_query($query = "SELECT timediff(time_allowed, time_used) as time_diff FROM scheduled_time WHERE scheduled_time.id = 1");
$record = mysql_fetch_assoc($result);
if ($record['time_diff']> 0){
print $record['time_diff'];
} else {
print "Time is negative";
}

Any help would be greatful.

View Replies !
Greater Than, Smaller Than For - Negative Number
Is negative numbers reversed when using greater than

(>) or smaller than (<) So '-7' is greater than '-3'.

View Replies !
Mt_rand Returning Negative Number
How come my mt_rand returns negative numbers while it shouldn't?

<?
//SMALL MT_RAND COMPATIBILITY TEST
$echoout=mt_rand(1000000000000,22000000000000);
echo"$echoout";
?>

Sometimes it gives me a positive number (i once had : 75587147 ) but mostly i get things like-216672647 I think it's because the numbers are so big. Is there a function that creates a random number between two bcmathic numbers. I already use bcmathic functions like bcmul and bcmod etc on my page because of the high numbers. Is there a function that can create a random number between to big numbers.

View Replies !
Mktime (negative Value?)
I'm working on editing a calendar program. It is a simple equipment check out calendar; the user selects the item and check out/in date and time to add a reservation. When I add a reservation on an item, I'm getting this error message:

QuoteWarning: mktime() [function.mktime]: Windows does not support negative values for this function in D:aedeconintranet
esources
esource_update.php on line 91
1198015200
1230760800
However, it does work and the reservation is added to the calendar.

Here is the code for the section where the problem is: Code:

View Replies !
Negative Numbers
How to check if a number $days is negative? i tried something with pregmatch to see if theres a - in the number but that dont work ne ideas?

View Replies !
Negative Time() ?
I need to store a date prior to the unix epoch, any pointers?

View Replies !
Negative Offsets
I was playing around with negative offsets:

select * from table1 order by col1 offset -5 limit 25;
select * from table1 order by col1 offset -25 limit 25;
select * from table1 order by col1 offset -250 limit 25;

They all return the same resultset (offset 0). Is
there even any point in allowing negative offsets -
such as maybe someday they'll offset backwards?

View Replies !
Negative Timestamps
From the manual, it seems negative timestamps should work on Linux, just not Windows. But anything I try before 1970, (i.e. a negative timestamp) is giving me
12/31/1969.
--
[ Sugapablo ]
[ http://www.sugapablo.net <--personal | http://www.sugapablo.com <--music ]
[ http://www.2ra.org <--political | http://www.subuse.net <--discuss ]

View Replies !
Php Cannot Accept Negative Value Returned From Cgi (c)
Using system()in php to call a cgi (in C), which in turn will return a status value. Whenever a negative value (eg -1) is returned, the php will show it as another value (255).
The sequence is like, -1 = 255, -2 = 254 ...If it is a positive value then it's working fine. Any idea on how to solve this and why is php behaving this way?

View Replies !
Negative SELECT In Mysql?
How does one retrieve the rows in a select statement that DONT match the
select.

select CarIndex FROM DealerCatalog, BigCatalog WHERE
DealerCatalog.CarIndex=BigCatalog.CarIndex

finds all the cars in the dealer catalog that are in the bigger distributor
catalog.

How do I do the opposite in a single sql statement i.e. all the dealer cars
that AREN'T in the big distributor catalog?

View Replies !
Imagecolorallocate Positive / Negative
my problem is the funktion imagecolorallocate().
in the manual i read : Col ist der Farbindex. Verwenden
Sie den negativen Index-Wert, führt das zum Aufheben
des Farbüberlaufs (Antialiasing).

it's german, but i think you know what i mean ..

$font_c = imagecolorallocate($image, 0, 0, 0);
that's the line .. and how to change $font_c into an
negative value ?

as noob i set $font_c = -1; but the some browsers shows
a red grafic and not an black one.

View Replies !
Date() And Negative Timestamps
It's annoying that my server doesn't play well with negative timestamps (with mktime and date).

The world did exist before 1970, right? I can't vouch for that myself, but quite a few people older than me claim to have been around back then.

I want a version of date() and mktime() that don't "choke" on dates from the pre-disco era. (PDE)....

View Replies !
Adding Negative Numbers On Solaris
I get an unexpected result when I add two negative numbers in PHP on
SPARC/Solaris 8. The same program works fine on Intel/Linux. I'm using
PHP 4.3.1 on both systems.

Here is my program, test.php.

<?php
$a = 0x81234567;
$b = 0xF0000002;
printx($a, $b);
printx($a, intval($b));
printx(intval($a), $b);
printx(intval($a), intval($b));

function printx($a, $b) {
$c = $a + $b;
printf("%08X (%u) %7s + %7s = %7s
", $c, $c,
gettype($a), gettype($b), gettype($c));
}
?>

I run it from the shell prompt like this:
php -f test.php

Output on Intel/Linux, PHP 4.3.1

71234569 (1898136937) double + double = double
71234569 (1898136937) double + integer = double
71234569 (1898136937) integer + double = double
71234569 (1898136937) integer + integer = double

This is the answer that I expect. I am adding two 32-bit integers, and the
value overflows.

Here is what happens when I run it on
SPARC/Solaris 8, PHP 4.3.1

FFFFFFFF (4294967295) double + double = double
71234569 (1898136937) double + integer = double
71234569 (1898136937) integer + double = double
80000000 (2147483648) integer + integer = double

When both arguments are negative doubles or both are
negative integers, then it gives the wrong answer.

What is causing this, and how do I avoid this strange behavior?

View Replies !
Negative Lookbehind Assertion With Eregi_replace()
I have this regex which matches full and partial URLs and converts them to links:

$regex = '(http(s?)://)?(([[:alpha:]]+.)+(com|org|edu|net|gov)(/[^[:space:]]*)?)'
$text = eregi_replace($regex, "<a href="http2://3" target="_blank">13</a>", $text);

Now I need to modify it so that if there is an @ before the partial URL, it does not match. (I have a separate eregi_replace() for doing emails, obviously). I tried adding (?<!@) right before the first set of ((. (Also, then my 3 change to 4) When I did this, it gives me the error: Warning: eregi_replace() [function.eregi-replace]: REG_BADRPT in /srv/test/htdocs/convert_urls/convert.php on line 33. Any ideas what I'm doing wrong?

View Replies !
Using Strtotime()
Lets say I have a variable $time = 'Apr 30 2007 7:00AM'. Is there a function that I can use or a way of using the strtotime function to see if that variable $time is between the hours of 7am and 7pm?

View Replies !
Strtotime
I am trying to compare 2 dates, so that if a post is older that 90 days the user is not allowed to edit it.

i am storing the post date in mysql in datetime field (2007-04-21 10:53:07). My question is how to user strtotime function to compare the NOW() date&time with the stored one, so if greater that 90 days return true.

View Replies !
A Bug With Strtotime
Something seems to be wrong with the strtotime function in PHP5. I've created a staff resourcing database, which is used to assign staff to projects on a weekly basis. The database stores assignments against a week ending date, which is derived using: PHP Code:

$week = date('Y-m-d',strtotime('Sunday'))

This works fine, $week is set to the current week ending date (Sunday) using this. However, I also create $nextweek and $lastweek using: PHP Code:

$nextweek = date('Y-m-d',strtotime('next sunday',strtotime($week)));
$lastweek = date('Y-m-d',strtotime('last sunday',strtotime($week)));

This has also been working fine, until we got to week ending Sunday 30th October. For some reason, when $week = 2005-10-30, $nextweek becomes 2005-10-05, which is a Saturday. I've tried replacing the 'next Sunday' with '+7 days', but this returns the same date. Is this a bug? Am I missing something?

View Replies !
Strtotime &
I've got a question and was hoping someone could offer some assistance. I've got this simple line in a test file. PHP Code:

echo date("Y-m-d", strtotime("next Monday"));

Here's my results using different versions of PHP:PHP 4.4.7: 2007-11-04PHP 5.1.2: 2007-11-05PHP 5.2.3: 2007-11-05
Todays date is November 03, 2007 (2007-11-03).

View Replies !
Strtotime()
<?php
$current = date ("F", strtotime("now"));

$next = date("F", strtotime("next month")); //or try "+1 month"

echo $current.'...'.$next;
?>

View Replies !
Problem With Strtotime
I am stucked with strtotime to convert date earlier than 1970 into time.
Is there any other way to convert older dates between 1900-1970 into time?

View Replies !
Strtotime 30mins Ago
How can I use strtotime to return the time 30 mins ago, for example:

date("ymd H:i:s",strtotime("-30 minutes"));

View Replies !
StrToTime () Issue
I'm using strtotime to get the timestamp for midnight. I have a statistics
script for my pagecounter that displays hits since midnight.
I also display the number of hours and minutes passed since midnight.

$start = strtotime ('today 00:00');
$timepassed = date ('H:i', time () - $start);

The weird part is at 11.30 AM it says 12 hrs and 30 minutes have passed.
I tried adding GMT+1 like so: $start = strtotime ('today 00:00 GMT+1');
because I suspect the fact I'm in Holland is the reason for the
miscalculation.
But this format is refused by strtotime. (-1)
Does anyone know
a) whether this is indeed the problem, and
b) how to fix it. Preferrably not alone for me here, but in suc a way anyone
around the globe would have a correctly working script if they'd use mine.

The php page for strtotime pointed me to a link at gnu.org where the syntax
for it apparantly is listed, but I get a no such page error.

View Replies !
Strtotime And Cron
I've got a db of events which have dates attached to them which have been created using strtotime().  They don't have any time.. just the date.  I've got a script which gets today's date using strtotime("today").  I use this as a comparison to find events which happen today.  This works fine when I call the script from a URL, however when I called the php file from a cron job... the strtotime("today") creates values which are different each time.

Are there any thoughts on what could be causing this?  Firstly, I was wondering if the cron job was somehow using a different timezone to me (I'm On GMT).  How do I explicitly tell php to use GMT.. .but then again.. this should matter too much, because I jsut want to date not the time!  It also wouldn't account for the changing values of strtotime("today").

Just out of interest, does php4 and php5 handle strtotime("today") differently?  I'm just wondering if cron is using the correct version of php?

View Replies !
Strtotime Question?
I have a string that looks like (a series of them)

1 Sep 2007 21:06:11
2 Sep 2007 13:45:31
2 Sep 2007 13:45:31
3 Sep 2007 01:40:42

and I want to go strto time on it any ideas its return -1 right now so I know somethings wrong.

View Replies !
Date Strtotime
i am trying to right a date into the mysql database but when i get the date from the html form and do strtotime on it it goes to an invalid date (by this i mean it is not the date i entered in the html form so for example 22-06-2007 changes to 28-11-2027).

View Replies !
Remove 0 From Strtotime?
Like every other blog in the world, I have mine displaying the date and time of each entry. Right now this is what I'm using:

echo date('h:ia', strtotime($r[date]));

My latest entry's time is displayed as 07:56pm. How do I remove the 0 when the hour is a single digit?

View Replies !
Strtotime(date('m/d/Y'))
does the following code give the correct time:?strtotime(date('m/d/Y')) or do I need to use : strtotime(date('d/m/Y'))?

I tried to find out which way the month and day work, but can't seem to find anything that will tell me.

View Replies !
Strtotime() Pre-1970
if I code

$birth = strtotime(&#391; April 1950');

then $birth = -1, I guess that this is because time "began" on 1st Jan, 1970. (although I seem to remember a few good times before that). So, what's the easiest way to find out how many days old I am (exactly, please, not just taking 1 April 1970 and adding 20 *365, which does not account for leap years?

View Replies !
Strtotime Failure
I don't know how I should input date + time into a strtotime function (i'm a total noob) so I tested this:

<?
$d=01;
$M=01;
$y=1970;
$h=01;
$m=01;
$s=01;
echo "$d $M $y $h:$m:$s";
echo strtotime("$d $M $y $h:$m:$s");
?>

I get as echo strtotime '-1', wich means the strtotime has a failure. Can anybody explain me why? Or can anybody tell me how I can make a strtotime function that puts a timestamp in the database depending on the date and time inserted in a textbox? (one textbox or one textbox to insert the day, another to insert the year,...) I should be able to change a format like (for example) this : 01-02-1990 00:00:00 (midnight) into a timestamp. so dd-mm-yyyy hh:mm:ss (or something else just to make it work)I'm clueless.

View Replies !
Strtotime With Days
On this - "next Thursday" is that next thursday or the next thursday ie: on wed will it show tomorrows time or the next week? PHP Code:

<?php
echo strtotime("now");
$timestamp = strtotime("now");
echo "  ";
$str = date('l dS of F Y h:i:s A', $timestamp);
echo $str;
?>

<p>

<?php
echo strtotime("next Thursday"), "";
$timestamp = strtotime("next Thursday");
echo "  ";
$str = date('l dS of F Y h:i:s A', $timestamp);
echo $str;

View Replies !
Strtotime Problem
How do I find the number of seconds from a certain date to the current? I have logged in my database a completion date within the past year and I want to figure out how many seconds it has been since the completion date until now. I know the strtotime command is fairly versatile and I have tried the following without the right conclusion: PHP Code:

strtotime("since ".$completion_date);
//and
strtotime("from ".$completion_date);

What do I need to do to fix this?

View Replies !
Why Doesn't Strtotime('') Return -1
instead of the warning message:
strtotime(): Called with empty time parameter in ...

Any good reason?

View Replies !
Strtotime Busted
$thing = "2005-10-01";
$storedDate = date("z",strtotime($thing));
echo $storedDate;

it just alwats returns today's date, ive tried it on a php5 server and it worked fine however on the server I need this one it is PHP4.2.

View Replies !
Strtotime Missing A Zero In Minutes
I am working with strtotime. The following problem occurs when using this function:

View Replies !
Strtotime - Setting From Present
I am having trouble setting the strtotime function to echo 'Y-m-d' on any day from 1 - 24 months past.

I have attempted the following from links that call to different ranges of dates; 6 months, 9 months, 12 months, etc. -- from present time:

My SQL is set up as follows:
WHERE Date between 'pastDATE' and CURDATE()
pastDATE = $HTTP_GET_VARS["getDATE"]

<a href="oldies.php?getDATE=<? echo strtotime ("-6 months ago"); ?>"> 6 MONTHS OLD </a>

How can I echo the strtotime as "Y-m-d"?

View Replies !
Strtotime() - Compare Two Dates
i dont get the format for it, say i have a date 06-06-2003, will it read that as month/day/year or day/month/year?

what about mysql dates. 2003-06-06 how does it read those? i just want to compare two dates.

View Replies !
Strange Strtotime() Behavior
I'm trying to use the strtotime() function to manage sessions. But I
get the following

<?php
print(time() . " - " . strtotime("+1 hour"));
?>

outputs:

1097380666 - 1097308800

Strange strtotime("+1 hour") produced a time stamp less than the
current time. It also never changes. In other words strtotime("+1
hour") always results in the time stamp 1097308800.

I have also tried strtotime("+1 hour", time()) with the same result

Is this correct, have I misunderstood the strtotime() function?

I'm running Gentoo with kernal 2.6.8.1, php 5.0.1, apache2

View Replies !
Displaying A Date With Strtotime
I have successfully used strtotime to format the date on a webpage that is
pulled form a MySQL database in the form yyyy-mm-dd.

However, in another part of the webpage, I have to insert another date that
may contain a NULL entry in the database. If I use strtotime to format this
then it enters the current date, whereas I want it left blank.

View Replies !
Strtotime And A Very Mysterious Date
Namely the thirteenth of December 1901, 12:45:52, Pacific Time.

All dates later than this passed in format "yyyy-mm-dd hh:mm:ss" to the
strtotime function return the correct unix timestamp value (as can be
verified by passing it back to date()).

If a date earlier than 1901-12-13 12:45:52 is used, it returns an error.
I tried this for a while to find the exact cut-off point, and this is it.

Any reason - possibly a limitation of the integer value that is used? I
didn't find this documented anywhere...

View Replies !
Strtotime - Use Abbreviations For Week
I'm pretty sure I used to be able to use abbreviations for week (w), days
(d), etc in strtotime (e.g. strtotime("-3d") = 3 days ago), but now it
doesn't work as expected unless I specifiy the whole word ("-3 days"). Has
anyone else come across this ?

View Replies !
Comparing Dates With Strtotime()
I'm building a schedule script--well, modifying one I built last year--to add an event every second and third Sunday of the month.  However, when I try to find that Sunday, and compare to my timestamp, I run into trouble: $myDays = getMyDays(); Code:

View Replies !
Use Strtotime To Convert A Date
I am trying to use strtotime to convert a date, gathered from a database, and add 21 days to the date. Example:

Date from MySQL record is 2007-01-01 I need it to be echoed to the browser as 2007-01-22.

Here is what I have now but it just outputs the database date without adding the 21 days.

$requested = date('F jS, Y', strtotime($row['letter_requested'])); //Convert to letter requested date
$sendBy = strtotime($requested, '+21 day');
echo $sendBy;

View Replies !
Getting Consistent Results With Strtotime()
I am having a problem getting consistent results with strtotime().  I am taking user input from a text box, and converting it into a timestamp in GMT.  Here is the code (I'm using PHP 4.4.4): Code:

View Replies !
Strtotime - Data That's Output From My Db
I have data that's output from my db in the form Sunday 9th September 2007 21:29:22.

I'm getting it by using

<?php

$timestamp= $row['timestamp'];
echo date('l jS F Y H:i:s', strtotime($timestamp));

?>

I'd like to add 19 hours to it, but have no idea how to.

View Replies !
Difference Between Two Dates Using Strtotime
im having some problem regarding strtotime and date function.. i want to find the difference between two dates using strtotime.. and then use the difference in loop to determine the dates between the two given dates... but instead of year 2007.. the output year is 2001.. how come? here's my code:

View Replies !
Strtotime - Get The Dates Converted?
I inherited a website with an SQL database. I need to pull information from the database into Excel for future use but the date fields are in strtotime from what I can tell. (Example: 1149996306). Is there a formula I can plug into Excel that would allow me to convert these dates to actual dates I can use? Or is there a SQL script that I can insert in MySQL or Access to get the dates converted?

View Replies !
Strtotime And Date Functions
I'm trying to add 3 days to a stored starting date:


echo $_SESSION['start_date']."<br>";

$new_timestamp = ($_SESSION['start_date'] + strtotime("+3 days"));
$new_date = date('Y-m-d', $new_timestamp);

echo $new_date;

This ouputs:

2007-02-18
2007-02-25 (which is clearly + 7 days?)

I would expect it to output:

2007-02-18
2007-02-21

View Replies !
More Date / Strtotime Confusion
I have an editable form, that (upon other things) retrieves a date from mysql. To prepopulate this text field, I use:

$result = mysql_query("SELECT DATE_FORMAT(Expiration_Date, '%d-%b-%y') AS DateX FROM MyTable) or exit(mysql_error());

Which will return (for example): 01-Jan-06

I have a dropdown field that a user can use to select the number of days to add to this date. In addition, however, the user should also be allowed to opt to not use the dropdown, but type in the value instead, in the d-M-y format. Code:

View Replies !
Problems With Strtotime Function
Im having trouble getting the the correct answer when I take one strored time away from another. Code:

View Replies !
Validate Each Row Against A Varying Set Of Keywords Some Exact Some Broad And Some Negative Exact
I have a datafeed and I want to validate each row against a varying set of keywords some exact some broad and some negative exact and negative broad if that makes any sense ultimatley these will be stored in a database and be feed specific.

here an example of what i mean lets say I am look for PC's I don't want software furnature Apple Macs or accessories I have already applied a price range filter Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved