brown2005 Posted December 8, 2006 Share Posted December 8, 2006 hi i currently have$adverts_link_date = $adverts_array['adverts_link_date'];$adverts_link_date_date = ;$adverts_link_date_time = ;but i have totally forgotten how to split the date and time up. its stored in mysql as date/time.thanks richard Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/ Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 I dont understand. Maybe you are looking for the function [url=http://php.net/explode]explode()[/url]?Orio. Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/#findComment-137392 Share on other sites More sharing options...
brown2005 Posted December 8, 2006 Author Share Posted December 8, 2006 say in the database i haveadverts_link_date = $adverts_array['adverts_link_date'];isadverts_link_date = "2006-12-08 10:38:14";i want$adverts_link_date_date = 2006-12-08;$adverts_link_date_time = 10:38:14; Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/#findComment-137393 Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 In you case, the sperator is a white space.So-[code]<?php$temp = explode(" ",$adverts_array['adverts_link_date']);$adverts_link_date_date = $temp[0]; // Everything before the white space$adverts_link_date_time = $temp[1]; // Everything after the white space?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/#findComment-137395 Share on other sites More sharing options...
brown2005 Posted December 8, 2006 Author Share Posted December 8, 2006 yeah cool, what happens if i wanna change the date fromyyyy-mm-dd to dd-mm-yyyy Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/#findComment-137396 Share on other sites More sharing options...
brown2005 Posted December 8, 2006 Author Share Posted December 8, 2006 can ne1 help with the above please? Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/#findComment-137526 Share on other sites More sharing options...
ted_chou12 Posted December 8, 2006 Share Posted December 8, 2006 Trying replacing the figures below with yours and see if it works:[code]<?php$old_format='2003-12-01 18:46:20.0';$new_format=date('m-d-YH:i:s',strtotime(substr($old_format,0,strpos($old_ format,'.'))));echo $new_format;?>[/code] Link to comment https://forums.phpfreaks.com/topic/29907-date-and-time/#findComment-137532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.