I need help with formatting date from mysql! with php!


Posted on 16th Feb 2014 07:03 pm by admin

Hello guys

*Note: this is a php question not MySQL question, please do not move it to mysql section! Thank you.

anyway, I have a record from the database as 2009-12-31 23:59:59

I needed to when ever I pull that record, I need to change it to mktime() format, so I can do so many things with it.
I tried to change it through preg_replace!



$str = "2009-10-13 11:30:15"; // an example only of the format data pulled from the DB!
$pat = '/(d{4})-(d{2})-(d{2}) (d{2}):(d{2}):(d{2})/';
$replace = 'mktime(4 ,5 ,6 ,2 ,3 ,1)';
echo preg_replace($pat, $replace, $str); // which give me the exact string of mktime(#,#,#,#,#,#)!


Please help me out!

Thank

No comments posted yet

Your Answer:

Login to answer
238 Like 7 Dislike
Previous forums Next forums
Other forums

Help with some dates
I have a list of dates in an array:

$mondays = array(
strtotime("October 12, 2009

Slow data retrieval which requires improvement..please help
I am working on a Help Desk Ticketing system and have a page called MY TICKETS which shows all ticke

Multidimensional array problems in $_POST
I'm having trouble with a three-dimensional $_POST array. It starts as a two-dimensional array on th

Receive Rosettanet Message to SAP 4.6c
Dear all ,

My customer will send the PO details by rosettanet message , Is it

Strange array issue, never happened before.
mysql_fetch_array returns 1 array per call. Generally that's why it is inserted into a while statem

redirect standard error and assert (how to?)
How do you redirect standard error and assert?

---

(Why? I am creating an web app and

jquery validation in codeIgniter
hai i need to add client side validation to my fiels which are selected in a forloop.the fields are

Troubles with a spider class
I am building a spider that will crawl through random whitepages (eg. anywho.com, switchboard.com, w

Extending Exception to contain method name
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a

Hardcopy printing is to wide
I want to make a hardcopy at runtime of my active form like this

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash