Datetime Within Past Week
I have a series of records in a database. When each record is stored,
the datetime is logged: $date = date("Y-m-d H:i:s");
Prior to adding a new record to the database, I want to run a query to
retrieve all of the records uploaded in the last 7 days. I thought it
would be easiest to:
Pseudo Code:
$newDate = $date - 7 days;
select * from TABLE where DATE $newDate;
Problem is I can't figure out how to subtract 7 days from $date and
convert that value to a valid datetime object.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Get € Past A XML Parser
I'm having troubles getting the euro sign through an XML parser. With the following test code: <?php $string = "<root><test>€</test></root>"; $parser = xml_parser_create(); xml_set_character_data_handler( $parser, 'cdata' ); xml_set_element_handler( $parser, 'starthandler', 'endhandler' ); if( !xml_parse( $parser, $string ) ) { print xml_error_string( xml_get_error_code( $parser )); } function cdata( $p, $data ) { ...............
Variables Past By Get And Post
I'd like a generic include that goes at the top of all pages that mysql escapes the variables past to the script. Is there a way to refer to the each of the variables past, for example (in pseudo code): for(each $XX in (list of get/post variables)) { $$XX = mysql_escape_string($$XX); }
IP Adresses (getting Past Proxy Servers)
i can capture IP addresses with no problem using $HTTP_SERVER_VARS['REMOTE_ADDR']. this works for people with static IP addresses just fine, however people who use DSL have dynamic IP addresses and i can't match people up to their IP address this way. i need this for a site where i want to only allow people into the site from the IP address that i got from them the first time they registered, i can't use $HTTP_SERVER_VARS['REMOTE_ADDR'] for this, apparently. the only way i've seen people claim to get past proxy servers is on php.net where they said that $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] would work. however, my php engine doesn't even seem to recognize this variable. this is also important in banning people from message boards and other IP specific situations. are there any other ways of tracking users specifically by what machine they are using?
Time Like Machine To Capture Website In Past
I want to create a section that will allow users to visit the site as it was in the past. All the data of the site is stored in MySQL. Here is what I'm having trouble with. A few sections are updated daily and a few only weekly. So if someone enter 10 Dec 2002 I want the site to show that days stuff. However if on this day section D contained the same content as 8 Dec 2002 because there has been no change how would I show this? I was thinking of using strtotime() with a -day type function? Conceptually would this work? How would I cross reference or search for the closest date in the past to the date being selected? Should I use Unix timestamp or just getdate() and then plug the values into seperate fields that match for day, month, year? I'm trying to understand the value of Unix timestamp and have read numerous post but I do not see why it is more useful than just plugging numbers into seperate fields for day month year. Thanks for any help you can give me.
PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last Sunday, and the Sunday before that? For example: Today is Thursday, August 18, 2004 (2004-08-18). I would like to have the following variables: $this_past_sunday = 2004-08-14 $two_sundays_ago = 2004-08-07 $three_sundays_ago = 2004-07-31 etc. etc.
First Day Of A Week
hi, i want to know the range of date for a week example : week 3 of 2001 monday is ?? sunday is ?? how can i do with PHP ?? tx
Day Of Week ?
Is there a way I can obtain the day of week - If I have the day, month, year ? (not via the time function - But from a database....) Im looking through the calendar and date functions -But can't locate anything suitable...
Day Of The Week?
is there a way to get the day of the week in php? i want to get the correct values monday, tuesday, wdenesday, etc. for the actual day it is.
Getting Day Of Week Out Of Datestamp
I currently have a datestamp in the format yyyymmdd. I want to pull the day of the week (Monday, Tuesday, etc...) out of that datestamp at any given time. Currently my code looks like this: $datearray = getdate($firstdatestamp); echo $datearray["weekday"]; When $firstdatestamp = 20000501 (or the first of May, 2000) the weekday returned is Thursday when really it should be Monday! I tried: echo date("l", time()); and it gives me the right weekday but only for the current date. I need to pass this my datestamp and am not too sure how.
Getting Day Of The Week From A Date
I tried searching the old postings, but to no avail. I am trying to figure out a way to get the day of the week from a date. Basically, I have a date in the format of 05/02/2003 (but I can change that format easily) and I need to have my program figure out which day of the week that was. All of the dates that I have will have already passed.
Date Of The Week
Can anyone help me? I am trying to work out the timestamp for the first DATE (not day) of the current week and last date of the current week. Any ideas?
Date To Week # Fct
I'm searching a PHP function that would translate a date in the following format yyyymmdd to the week number in the year... ex : 20040128 => 5 i.e. jan 28th 2004 gives week nb 5 in 2004.
Week Of Year
Is there a function which returns the week of the year, given a specific date?
Getting SQL Rows For A Week
I have a database that uses two date fields for tracking information. The first field is for the addition of the record and the second is for the expiration. I have a small section that I want to list records that will expire in the current week (or for that matter in the next 7 or 14 days). What is the syntax that I would use to call mySQL with to get that info.
Week Of The Month
I need to determine the week of the month (1-5) so I can rotate menus for a cafeteria. Is the following, which I know prints the week rather than storing it, the simplest or easiest way to determine the week? PHP Code:
File Of The Week?
I wish to add an automated "file of the week" feature to a site for users to download. I was having a little trouble explaining this.... So I ended up making these few points on the functions of the script I'm aiming for: - The script finds the folder with the files for the current week. (If the download was a wallpaper, there would be files for different resolutions, and therefore more than one file.) - Links are then made to the files. - Every week, the links are updated for the new files for the current week. I was thinking along the lines of putting the weekly files into folders named after timestamps and going from there... Is that the way to go? And how would it be done? I can't quite figure this out.
Printing Every Week
im trying to print a list of every Friday since a date defined. Let me try and explain. I want to define a date such as 2007-07-06 (which is a Friday) and then let php print each Friday since that date until today. For example, if the date defined was 2007-07-06 then it would print 2007-07-06 2007-07-13 2007-07-20 2007-07-27 2007-08-03 2007-09-14 But I want to also be able to format the date it outputs, so it might look like Friday 06 July 2007 Friday 13 July 2007 Friday 20 July 2007 and so on.
Week Before Date
Im looking to get the date 7 days ago. I know how to do 7 days ahead: $timeStamp = strtotime($oLastBatchDate->Last); $timeStamp += 24 * 60 * 60 * 7; $NextBatchDate = date("Y-m-d H:i:s", $timeStamp); However, does anyone know how to do 7 days back?
Date And Week
I am looking for a way to determine the week of the year if i have a date.i know that date("W"); give me the week Number but not sure how to determine the week based on the date.
Day Of The Week Program
I am trying to write a program that will give me the day of the week without using the date function. I input the date and it's supposed to spit out the name of the day of the week. Here is what I have so far. I don't know quite what to do next. Code:
Date Of The First Day From A Given Week Number
I need some help to figure out the date of the first day in a given week number. Let's say that I pick week number 23, I want to retrive the day of that monday in week 23.. I've been searching the net for days without any result.
Current Week Number
how I can split the month out into 5 weeks... then to have the week number printed and when the current week ends it will increment to the next week number. For example today is 3rd of July, therefore we are in week 1 of the month. Next week will be week two. I want it to go back to 1 at the start of the next month though.
Date Out Of Week Number?
I would need to get a date out of a week number, for example for week 52 the first date, 25/12. In my system the user inputs a week number, and then I would like to display a popup list of all seven dates for that week, for her to choose from. Is there a handy function to do this, or can you think of any way to achieve this?
Handling Week Number
I have been reviewing some calenders classes and have notice that if u uses us written class with displays week number it ll by wrong for eu. so to my question how do you handle week numeration depenting on country? is there any simple solutions for this?
Mysql WEEK() Function
In mysql WEEK() function it specify the number of week of a specific date. For example January 02, 2006 will return a value of 2. Now my problem is how could i be able to determine the range of that value in a week like a value of 2 will be equal to January 1, 2006 - January 7, 2006.
309833 Web Views Last Week
This number seems about 30 times higher than normal for this group. The group usually sees 10 times less traffic than the CakePHP group.
Month From Week Number?
Has anybody here ever made or seen a function which when passed year and week number in that year returns month ? actually what I want is all records from db starting from six months back till now and group them by weeks, and some weeks may have no record so they won't appear in resultset. But I have to display zero against these weeks. display has to be in form of Number of Records in Week # x of Month y e.g Number of Records in Week 2 x of Month Jan So my solution is to get records from db by this query: .. where abs(Week(Now()) - Week(RecTime)) <= 26 this works ok but I don't have any idea of which month and week of month was 6 months ago. So I decided to get week number and year of 6 months back and then write my function get month form this info.
How To Calculate The Day Of The Week By A Given Date.
I'm currently working on a (simple) calendar system which allows registered users to add an event to the calendar. The table EVENT stores info about the author, date and description of the event. I then managed to output a list in which only events of this year are showed and are grouped together by months. And now I only need one more thing to complete the script. I want to output for every event on which day of the week it occurs (monday - sunday). I've looked around for tutorials but haven't found a basic one.
Date Function For Week Before
Im looking to get the date of a week before a certain date For example: $iLastDate = date("Y-m-d H:i:s "); $timeStamp = strtotime($iLastDate); $timeStamp + = 24 * 60 * 60 * 7; $NextBatchDate = date("Y-m-d H:i:s", $timeStamp); This is for a week ahead, how do I do a week before?
Week Ending Dates
When a user logs on, he should have a drop down selection box of week ending dates that would include any week ending dates that he hasn’t completed time for, only going back as far to a specified date and then also the current week he is within and up to 1 week forward. The week ending dates should always be on a Sunday. The table I have is as follows; CREATE TABLE `techs_pay_weeks` ( `tech_pay_week_id` int(11) NOT NULL auto_increment, `tech_pay_week_ending_date` date NOT NULL default '0000-00-00', `tech_id` int(11) NOT NULL default '0', `tech_pay_week_hours` float NOT NULL default '0', `tech_pay_week_amt` float NOT NULL default '0', `tech_pay_week_approved` tinyint(4) NOT NULL default '0', PRIMARY KEY (`tech_pay_week_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; The tech_id is held as a $_SESSION[userid] when he logs in. I understand how to advance a date, but not from a dynamic date that should always fall on a Sunday, and a current Sunday at that.
Constraint Using The Days Of The Week?
I am developing a property application where I have 5 members and only want 1 member a day to choose their property for the "property of week" section. So I want to assign a day to each member. Mem1 - Mondays Mem2 - Tues Mem3 - Wed etc.. Each member will have there own unique logon so if Mem1 logs in on Monday, they will have the "property of week" option avaliable to them. Mem2 will have it Tuesday and so on.
Work Out Day Of Week From Given Date
I'm using a date picker to choose a date. the format of the date entered into the textbox is yy/mm/dd From this how can I work out the day of the week from the entered date? I need this as the first day has to be a sat, and if it isnt my form will tell the user to choose a saturday. Is there a simple way of doing this?
How To Remove Entries In A DB That Are A Week Old?
I ahve a social network and I have a bulletin system, taht allows users to post bulletins that all their friedns can read... well anway, i dont want the bulletin to just sit there and take up DB space, how would i go about removing "bulletins" that are over a week old?
Datetime
The following might be either PHP or MySQL question: How can I calculate the diffirence in HOURS between two values in DATETIME format?
Datetime
I have a table which have a datetime column. When I touch (update, Insert) a row in the table I would like to update the value of the datetime column. How do I do that? I have tried to use the function now() but MySQL doesn't seem to support this function. Does php have a function I can use for capturering the servertime?
Datetime
So I have a certain date in a table (and the type of field is datetime), what code would show what that date would be in 7 days? I'm having each row expire after 7 days, and I want to be able to make a countdown of how many days/hours/minutes are left until it expires.
Datetime
i put a datetime column in my mysql table what php code do i need to get the time and add it into the table?
Automatic Display Of Events Each Week
I know how to display a list of upcoming events from a SQL database, but am wanting to display the events based on the date, eg. events happening this week only. Could someone tell me how to do this or point me in the right direction please?
How To: DELETE * FROM Table WHERE Greater Than 2 Week
I am building a module that displays the headline from a page that had the most hits last week. I was able to figure this out in PHP. I would now like to know how to delete and records that are over 2 weeks old. Anyone know how to do this in the mysql query?
Delete Entries 1 Week Old Or Older.
I have a query that's supposed to remove bulletin entries that are a week old and over, but its not working, and the "date" column is filled with "time();" <?php mysql_query("DELETE FROM `bulletins` WHERE `date` > (time() + (3600*24*7))");?>
Getting Day Of Week From User Defined Date?
is there a way to do this? e.g. i have three drop down boxes in html asking the user for day (1-31), month, year (2007 or 2008) i then have: // get user input $start_day = $_POST["start_day"]; $start_month = $_POST["start_month"]; $start_year = $_POST["start_year"]; //echo $start_year; $the_date = $start_day . "/" . $start_month . "/" . $start_year; echo $the_date; say then i get an output as 13/10/2007 if the user enters that date, is there a way to get what day of the week this is?
Sql Datetime Problem
alright the problem i am having is i want to keep track of the days a person has been signed up for something. so i use this code...
Datetime Problem
I have a field called "LastUpdate" in a MySql table which is of type "datetime". Whenever that record is updated , i want to insert curent date and time in that field..like 2003-09-24 12:03:03 How can it be done?
Datetime Query
I am trying to insert the following query into a table field called last_login it does not seem to be updating the time the user logged in, the field type I am using is datetime on my table. $nowtime = mktime(date(G),date(i),0,date("m"),date("d"),date("Y")); $auth_query = mysql_query("select * from $dbtable where username='$user' and password='$pass' and last_login > '$nowtime'") or die("Could not execute query auth_query"); } if (mysql_num_rows($auth_query) == "0") { $timeout = mktime(date(G),date(i)+10,0,date("m"),date("d"),date("Y")); mysql_query("update $dbtable set last_login='$timeout' where username='$user' and password='$pass'") or die("Could not execute query"); }
Using PHP With MySQL Datetime
I'm using PHP with MySQL 4.x and was having trouble converting a datetime from MySQL into a formatted string until I ran across this solution that converts a YYYY-MM-DD HH:MM:SS string into a Unix-style timestamp and then formats it. $timestamp = "2005-04-06 15:43:34"; $time = strtotime($timestamp); print date('Y-m-d a H:i', $time)." "; However, it seems kind of counter productive. After all, aren't people (and RDBMs like MySQL) getting away from Unix timestamps for the a reason? I don't necessarily think that my code will last until the 2038 timestamp rollover but I would rather avoid timestamps if possible and am surprised that PHP doesn't seem to offer a better solution - like parsing the string into some sort of date object or array, and then formatting THAT into the desired string. Is there such a thing right now? It looks like date_parse() is a step in the right direction (http://php.net/manual/en/function.date-parse.php) but it looks like it is not available in a snapshot release and that's only half of the equation anyway. I could always write my own function to do what I am after but I would like to use something built in if possible. Any ideas?
Splitting Datetime
Im trying to split a datetime string. I can to it with the date but it is giving me problems with the time: $tourney[enddate] = the date $tourney[enddatetime] = date and time This is what i did with just the date: PHP Code:
GROUP BY On A DATETIME
Is there an MySQL query to group data on year-month using datetime(YYYY-MM-DD HH:MM:SS)?
Add 16 Hours To Datetime
I have a mysql database table that gets the "datetime" column automatically filled when a user fills in the php form page. $curdate = date("Y-m-d H:i:s"); Trouble is, the database server is in the USA which is 16 hours behind my time. Does anyone know a way to change this so that the 16 hours get added to the datetime?
|