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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

Email Form Syantax Issue 2
How to make this look FROM:"OUR TEAM" instead of FROM:abc@mail.com

$headers = "

Pipe email to PHP - get mail adress from MySQL - send?
Hi all,

this is the challenge:

1) Our faculty at the college where I'm employed includ

str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa

Intrastat Report Config in ECC 6.0 - goods Movement in EU countries
Colleagues, need ur help to understand the changes require in ECC 6 standard Report configuration se

ereg_replace()
Basically what i need to do is

$title = "This Suck's"

$striped = ereg_repl

Ajax Issues - Update Panel / Timer. Intellisense doesn't know about them
Type 'System.Web.UI.ScriptManager' does not have a public property named 'UpdatePanel'. That is wha

Google Map
I have done Google Map Integration for one my project. But for that we need the "latitude and l

help with database debug pls
Parse error: syntax error, unexpected T_ELSE in /home/content/m/e/s/mesick/html/students/05/php/chec

Need help with some php code :)
Hey! I'm quite new to this whole thing, so please don't fire me with shait on this one =D

I'm

First root of a number
Hi,

I can't find any function in php to give me the first root of a number.
Is there any

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