iiker Posted August 14, 2007 Share Posted August 14, 2007 I have a number, let's say 140820071211 (todays date and time at 12 11) and now i need to conver it to date format (ie 14. Aug 2007 12 11) How would i do that? is there any function that makes it to date (ei i give the date format i first used date('jmYGi'); and it returns the date ?) Quote Link to comment Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 So, from a timestamp to a legible date format? Quote Link to comment Share on other sites More sharing options...
iiker Posted August 14, 2007 Author Share Posted August 14, 2007 well, yes Quote Link to comment Share on other sites More sharing options...
iiker Posted August 14, 2007 Author Share Posted August 14, 2007 now i tried $number=140820071211; date("j-m-Y-G-i",$number); but outcome was : 19012038514 -> 19. jan 2038 5:14 ????? Quote Link to comment Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 iiker.. Take a read about date/time on W3schools with this link: http://www.w3schools.com/php/php_date.asp I'm sure you can solve it with that mate! Quote Link to comment Share on other sites More sharing options...
iiker Posted August 14, 2007 Author Share Posted August 14, 2007 well now i understand, but theres still a problem. my number isn't a timestamp. its just a date and time pushed together and now i need to separate it again. using functions in w3schools's page gives wrong result. function date(format, timestamp) requires timestamp that i don't have. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 14, 2007 Share Posted August 14, 2007 well you can use substr to pull out the relevant parts. you need to know which parts are what of course... Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted August 14, 2007 Share Posted August 14, 2007 <?php $timestamp = 140820071211; $unix_timestamp = mktime(substr($timestamp,8,2), substr($timestamp,10,2), 0, substr($timestamp,2,2), substr($timestamp,0,2), substr($timestamp,4,4)); echo date('r', $unix_timestamp); ?> date() only takes UNIX timestamps. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 14, 2007 Share Posted August 14, 2007 apparantly that number is not a timestamp dan... so the only solution is to take the string and spilt it up just and a position - so take first 2 digits as day, next 2 as month etc.... this requires that the data is a string and that leading zeros are maintained so that the 'number' is always a uniform length Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted August 14, 2007 Share Posted August 14, 2007 Isn't that what I just did? o_O I think you missed line 3. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 15, 2007 Share Posted August 15, 2007 LOLOL yeah I completely missed the substr bits -- as soon as I saw mktime I just saw red soz mate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.