monkeytooth Posted September 3, 2008 Share Posted September 3, 2008 Alright.. without the use of the MySQL Timestamp column... I want to make a single time stamp that I can break down 2 ways.. First way would be the typical mm/dd/yyyy or Mon. Day, Year with or without time 00:00am/pm Second way would be a timelapse.. How much time has passed since the timestamp to date.. So is the above possible with one timestamp, if so which type of timestamp would you suggest, and lastly since im tired and in a rush how? Thanks for any help Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/ Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 Why without mySQL TIMESTAMP? Do you want to avoid using database at all? Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/#findComment-632999 Share on other sites More sharing options...
monkeytooth Posted September 3, 2008 Author Share Posted September 3, 2008 I am using a database to store some of the timestamps I am intent on using.. however. I dont have a need for them to update when the row is updated itself. The main timestamp I am posing this question for is for 2 purposes One is as the anniverary date, Two as an expiration factor. I suppose I could use more then one timestamp per concept, but that can end up getting messy later.. I will if I have to Im kind of on a deadline, but overall I want to avoid the hassel and keep things like that down to a dull min. I still run into the issue of the how though regardless.. I don't use any time functions that often, never really have a need for them, however my current client loves the idea of the concept mentioned for various reasons and logic. So to make him happy.. I must use the timestamp concept. Which brings me back to my previous question which method of timestamping would best suit me, and how would I use it as desired? Sorry if I seem cold, I am just workin on other aspects of this project while waiting for an answer.. and im just frustrated, its one of those days.. again, thanks in advance. Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/#findComment-633004 Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 You can set TIMESTAMP column not to update when row is updated. (In fact, only the first TIMESTAMP column in a table can be set to autoupdate). Remove ON UPDATE CURRENT_TIMESTAMP from field definition to get TIMESTAMP that is not autoupdating. Alternatively use DATETIME type, which can be used to stare same data, although its 8 bytes long not 4 bytes as TIMESTAMP. On the other hand, it can store larger range of dates. To display data in a format you like use date("format",strtotime($timestampFromMysql)); For "format" see date() To check time elapsed since timestamp, MySQL date time functions could be used: DATE_ADD() and DATE_SUB() Seems it's 'one of those days' all over the world today... Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/#findComment-633019 Share on other sites More sharing options...
monkeytooth Posted September 3, 2008 Author Share Posted September 3, 2008 Yea few of us here are having the day.. and im sure many out there as well.. But deffinately thank you for your help, I am actually packing up and getting ready to leave for the day, but as soon as I can make it home, ill try what you said see what I come up with and see if i can bend it to the liking of the boss.. Also did not know that about the timestamp column, i thought if it was implimented then its one of this it is what it is type of deals, and would update upon use.. Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/#findComment-633029 Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 Have a nice evening at least ;P P.S. I think this one function will be better for calculating time differences TIMEDIFF() Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/#findComment-633031 Share on other sites More sharing options...
DarkWater Posted September 3, 2008 Share Posted September 3, 2008 Also, TIMESTAMP actually formats the date, so you can always just store a timestamp in an INT column so you can work with the raw timestamp. Link to comment https://forums.phpfreaks.com/topic/122594-time-mktime-timestamp/#findComment-633057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.