Timestamp -> A Useful Date
hi, i want to display a formatted version of the next 7 days on a page. I can add so many seconds to a timestamp, but, how do i convert that timestamp into a useful formatted date?
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Order By Date When Date Not A Timestamp
I have a database of items with 2 fields, LogDate and LogTime. I would like to be able to display these items ordered newest to oldest. LogDate is a VarChar(11) and the format of the data is always DD-MMM-YYYY (30-AUG-2006) LogTime is a VarChar(7) and the format is always HH:MMAP (02:47pm) How can I order my SQL to sort by those 2 fields as if they were real dates?
View Replies !
View Related
Question About The "date / Time" Continuum - Timestamp Or Add Date As Varchar?
I have a new project that consists of work order tracking. It's nice cause I can use a lot of the same code from my last project which was delivery tracking. However when I tried to create a MySQL table using two timestamp fields, it stopped me. MySQL will only allow one timestamp. So I did some googling and now am thinking I can use the php date function to get the date format of my choice and post the results into a textfield then post to MySQL as a varchar. I'll still be able to sort date records the same in my queries and it's easier for me as a n00b to manipulate the data; Ditching the time and creating expressions / queries on timestamp fields gives me fits. Code:
View Replies !
View Related
Get Timestamp Of Date
I have a date object which I want to get the timestamp for. The date is 24/8/2007 18:30:00 I simply want to determine what the timestamp is for this date and time so that I can compare it against the current timestamp. The problem is that the timestamp is for the current time, not the date and time that I have specified. Here is my code: $mydate = date("d-m-Y : H:i:s", mktime(18, 30, 0, 8, 24, 2007)); $datestamp = time($mydate); echo 'My date: '.$mydate.' - Date stamp: '.$datestamp;
View Replies !
View Related
Timestamp To Date In Php
I really can't make sense into this to see why it's not working. I've looked at other examples on the net but I still get a weird date. I'm retreiving my date from a column called date llogin which is a datetime column which I'm storing using Date("Y-m-d H:i:s") I have the following: <?=date("d-m-Y", strftime($a1[llogin]));?> But it's giving me this date. 31-12-1969.
View Replies !
View Related
Date To Unix Timestamp
I am getting a date and time from a user. The send in a date with the format dd-mm-yyyy and a time with format hh:mm and then send in whether it is am or pm. now i split the date and time, then try to figure out the hour using: Code:
View Replies !
View Related
Mysql Date To Timestamp
I would like to use php to query a database and retrieve a unix timestamp. The problem is that mysql is storing the data in the date format and not a timestamp. I am sure that I can amend my query to format the date returned as a timestamp without having to do the conversion in php. Can someone tell me what to put in my db query?
View Replies !
View Related
Fetch The Date From Timestamp
i have a mysql table with 3 fields 1.id 2.time 3.approved values 1 1181237691 0 2 1181237703 0 3 1181237711 0 i want to fetch the distinct dates from this timestamp values using select statement. i want to display like this 1 2007-06-07 second thing i want to update the approved value=1 where these distinct dates are equal to the above timestamps.
View Replies !
View Related
Problem With Date() And Timestamp
I've used date() a million time before with a Unix timestamp pulled out of a MySQL database but this time it just isn't working as expected: <?php mysql_connect('localhost', 'x', 'x'); mysql_select_db('x'); $query = mysql_query('SELECT * FROM `pub_news` ORDER BY `date` DESC'); while ($row = mysql_fetch_array($query)) { echo date("nS F Y", $row[date])."<br>"; } ?> The two database values for the 'date' field are �' (5th May 2007) and �' (11th May 2007). The code outputs the correct values for the fields as $row[date], but date() displays both as 5th May 2007. I have checked the server time and although it's a few minutes fast, it seems OK. Am I being really stupid and missing something obvious?
View Replies !
View Related
Getting A Readable Date From Linux Timestamp
I have a form that exists from 3 separate dropdown-lists. The first list enables you to choose the year (YYYY) The second list enables you to choose the month (MM) And the third list allows you to choose the day (DD) To make a timestamp wich is easy to compare, I create a var. $date = "$year$month$day"; This var. combines the 3 values into 1 number (20030516) PHP puts this number into a mysql db as an integer(8). Now, while retrieving from the database, I would like to order by date, so 20030101 comes BEFORE 20030102. This is easy but I have a little problem: The date must be displayed in yyyy-mm-dd format after comparing it to today's date. So while retrieving, it is ordered by date and compared to today's YYYMMDD-timestamp. So: How can I make YYYYMMDD look like YYYY-MM-DD ? I prefer to do this with php.
View Replies !
View Related
SQL Date/time Or Unix Timestamp?
Generally when developing applications I use unix timestamps as the method of storing dates in a sql database. However, I was wondering if I should use the standard date-time used by the database. The question then arises: continue using PHP to manipulate the dates, or allow the sql server to take over. Can anyone provide any reasons to use sql date-time rather than unix timestamps?
View Replies !
View Related
Insert A Date Into A Timestamp In MySQL
I want to insert a date into a timestamp in MySQL as follows: $date = date('U'); $uid=$row['userid']; $updt = dbquery("UPDATE users SET last_login = '$date' WHERE userid = '$uid'"); This will not work for some reason. If I : $uid=$row['userid']; $updt = dbquery("UPDATE users SET last_login = NOW() WHERE userid = '$uid'"); I get a MySQL Datetime inserted.
View Replies !
View Related
Date Format / Timestamp Problem
I am facing one problem in php, mysql whenever i submit empty date to db, it automatically takes timestamp as 943900200 ('30-11-1999') which is creating problems in my application..... currently handling this problem by hard coding timestamp validation.
View Replies !
View Related
Converting A Date To Unix Timestamp
I have a form where people enter their birthday_day, birthday_month, and birthday_year Is there a way to do the following; convert_this_to_unix_timestamp($_POST['birthday_day'], $_POST['birthday_month'], $_POST['birthday_year']); The point is that if i store it as a unix_timestamp, then i can do some math on it and return the users age instead of their birthday.
View Replies !
View Related
Display The Date From A Mysql Timestamp
i'm just trying to display the date from a mysql timestamp in php. using this line: date('l dS of F Y h:i:s A', $PostDate); but for some reason that line gives me this date: Monday 18th of January 2038 09:14:07 PM and the time stamp in mysql database is: 20050830100156 any idea what going on here?
View Replies !
View Related
Setting Automatic Date (timestamp) On Db From Form
I'm setting up a web-page that will allow a group to post information about books that they've received and when they've received them. I would like the "date received" part of the form used for inputting information about the books to be set automatically and invisibly. However, I would need to be able to show that date as mm/dd/yy on a list coming from the MySQL db. The fields of the table are ID, Title, Author, Publisher & Date Received. Of these, only Title, Author & Publisher would be input manually.
View Replies !
View Related
Output Format For A Timestamp Date Variable
I have a variable - $lastdate - that is the latest date any record in a MySQL database was updated. Its MySQL format is TIMESTAMP. If I say [echo $lastdate] I get the output I'd expect - 20060424221549 which is a YYYYMMDDHHMMSS format. I'd like to be able to display that using a format of mm/dd/yy with no leading spaces on the month and day. I don't know what the php command is to do this. In other words, I'm trying to display a variable - $lastdate - formatted a certain way. I know that the formatting string n/j/y will get my output looking as I'd like, but I can't figure out how to apply that to my variable.
View Replies !
View Related
Text Input Of Date And Timestamp Fields
I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the best way to create date or timestamp inputs. Let's take a date in the format yyyy-mm-dd as an example. This is too error prone, I know my users will do it wrong <input type="text" name="fieldname"> Right now I'm thinking about something like this: <input type="text" size="4" name="y_fieldname">- <input type="text" size="2" name="m_fieldname">- <input type="text" size="2" name="d_fieldname"> but this is IMO a very ugly solution, because after the SUBMIT I have to glue all the parts together before inserting the values into the db. Something like this: <input type="text" format="yyyy-mm-dd" name="fieldname">
View Replies !
View Related
Effective Due Date? Timestamp? FATAL Error.
I'm building a library with php, and want to create a way for the return date for an item to automatically be 14 days after they are checked out. I had hoped to use something like: $Check_Out_Date=TIMESTAMP[(8)]; and then manipulate that with substrings and whatnot, until i could put it back together as 2 weeks later. Unfortunately I'm getting a FATAL error, with this.
View Replies !
View Related
Create A Date Field Of Type TIMESTAMP
I have a guestbook on my site. It uses a mysql database and holds names, email and a message. I'm trying to modify it so that it will also hold the date/time that reecord was submitted. So I want and created a date field of type TIMESTAMP to hold these values, and adjusted my php script to add another field. Now, when the guestbook is filled out, in my new field, all I get is a bunch of 0s. Why is this?
View Replies !
View Related
Unix Timestamp Into Textual Date Time
How do i convert a Unix timestamp into English textual date time description? In my database i have stored the date and time as 1187079740 and now i want it to be converted into 14/08/2007 13:52:20. I have currently used <?php $format = '%d/%m/%Y %H:%M:%S' $strf = strftime($format); echo "$strf "; print_r(strptime($strf, $format)); ?> I am generating data from a db to xml which gives date as <date>1187079740</date> Now my task is to convert SPECIFICALLY the value 1187079740 into it's actual textual form of 14/08/2007 13:52:20. I want the data 1187079740 to be written into a php script to generate it's textual time.
View Replies !
View Related
Regex Issue - Converting A Written Date To A Timestamp
I have a problem, somehow through one of my scripts, all the timestamps in my database were set to 0000-00-00 00:00:00. I can fix this because one of the fields contains the written date in this format "Wednesday, June 7, 2006", I think I need to make a regex expression that can read that and generate a new timestamp from it, I'm just not sure where to start because I've barely used regex. Some of the dates are not in that format because it contains over two years worth of data, and I want to just delete the ones that are not in that format as well. I'd appreciate any help here, I'm kind of stumped. Once I match the expression I can generate the timestamp, but I don't know how to match it.
View Replies !
View Related
Convert User Entered Date And Time To Unix Timestamp Before Inserting To Database
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard 0000-00-00 format of MYSQL so that I can do better calculations and queries.
View Replies !
View Related
Converting An SQL TIMESTAMP Into Unix Timestamp
I look over the docs on MySQL, and I'm assuming MS SQL will be quite similar. I am trying to decide how best to pull this off. I am anticipating a need to take the typical SQL TIMESTAMP and convert it to an Unix Timestamp... Now, as I look at this a TIMESTAMP stores namely a "numerical" format in a 14 Digit String. I'm just wondering if anyone has a suggestion as to how I might split this into the componenets (4d Year/3d Month/2d Day/HH MM SS) so that it could be passed through mktime() (which will give me the unix version). Actually, I think I may have an approach.. perhaps using the php substr() function.. since it returns a "defined" portion of a string.. if $x was our timestamp, we'd have to pass it through the substr() function a few times, to pull out the pieces we wanted.
View Replies !
View Related
Get The Todays Date- Yesterdays Date And Tomorrows Date
I get the todays date- yesterdays date and tomorrows date, like so: $yesterday = date ("Y-m-d", mktime (0,0,0,date("m"),(date("d")-1),date("Y"))); $tomorrow = date ("Y-m-d", mktime (0,0,0,date("m"),(date("d")+1),date("Y"))); $actualdate = date("Y-m-d"); Which returns the date in the format "200-11-13" But I need to add 13 hours to all three - how owuld I do this?
View Replies !
View Related
Timestamp On URL
how I can fetch the current time and parse it together with a URL. Example: Let's say there's text link. When I click on it should attach the current time to the URL as well. something like this : url=page.php3?<? echo "time()"; ?> (but that does not work) I think I've got the wrong syntax or something.
View Replies !
View Related
Getting GMT Timestamp
How do I fetch the current timestamp according to GMT? I don't want the actual date information, I want the actual integer value. I originally had date() - date('Z') but it does not always seem to work. Is there a better way that works all the time?
View Replies !
View Related
Timestamp
what i want to do is making a collum in my database wich autoatticly fills it self whit the date when a record is added i think i can do it best in php how do i do that?
View Replies !
View Related
Add To Timestamp
Just a simple question but I have gone braindead. How can I add 7 days to a 14 digit timestamp? eg 20050616000000. It needs to be able to loop and move between months so simply adding 7 to 16 wont cut it.
View Replies !
View Related
Timestamp Set
I've been through several tutorials but am still having a (what seems to be) simple issue. I have a timestamp set in a database for a user: $original_timestamp=timestamp when the user registered (in database) I would like to display a message to the user if upon logging in , it has been more than 24 hours since the last login date. Using php.net I think it would be some thing like: function ago($original_timestamp){ $difference = time() - $original_timestamp; $difference = round($difference / 60); if($difference > 24) return $difference." print it's been greater than 24 hours"; } } Is this close?
View Replies !
View Related
Timestamp Help
Well im trying to create a kind of community type website and have designed the database to insert a date everytime someone registers. Im getting a little confused as to weather i should use a date field or int field and should i use the date() function or the mktime() function? Basically one reason i want to insert a date is because i want to show the latest registered users on the front page. So i some how need to loop through the dates starting from the present back to a weeks time? If that makes sense, im also struggling on how this could be done.
View Replies !
View Related
Timestamp For...
the next Saturday at 12:00 pm? I have uploaded some files to my database, and for fairness reasons, I want to release the files to the public at the same time. $now = time(); How do I find the next possible Saturday at 12:00pm in relation to $now?
View Replies !
View Related
SQL Timestamp
I am trying to select rows from a db which are prior to the date of submission. SQL doesn't seem to like the format which PHP passes the time in. I've tried a few formats, but none seem to work, including the one which the data in the SQL db matches. PHP Code: // SPIT OUT NEW! $time = date('Y-m-d h:m:s'); echo $time; //just to check format: $new  = "SELECT * FROM `posts` WHERE `time` < '%time'"; $newcheck = mysql_query($new); if (mysql_num_rows($newcheck) > 0) {
View Replies !
View Related
Timestamp Query
When I pull the timestamp field out of the database it looks like: 20030507145411 Is there any way, I can make this look nice and pretty, like: 14:54, 7th May, 2003 I looked on here but couldn't find anything.
View Replies !
View Related
Timestamp Compare..
Hi there, I've got two sets of dates, start / end and start / end If I convert my dates into timestamps - is there a quick way to compare them & see if any of the dates overlap.. ? Im using a MYSQL database, & the dates are in text format - eg 20060527 etc (year month day).. Though - Im at the very start of the database - so would storing the start/end dates in Timestamps be faster ? (use a MYSQL query command ??)
View Replies !
View Related
|