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

code help - pagination
Hi all, I have this code, basically a user logs into my site and they get this page.

The pro

Update Database
Hi All,


I have a problem with this:

Code: [Select]<?php
session_start();

How do I use ValidatorCallout extender in Login control?
Hi,I'd like to customize the look and feel of the login control a little bit. One thing I'd love to

JSON SORT WITH PHP
I have two products that I want to sort by say "Id:17, value: xxx" using php
The page w

how to hide input fields on selection screen using variant attribute
Hello all,

I want to know how to hide input fields on selection screen using variant attr

Syntax error
hi im having a little trobble with this script
-------------------------------------------------

php email checker
I am having alot of trouble finding info on how to do these email things. I need to do the following

Sql and php order list script problems
Hi im having a few problems with trying to get the coding right on a orders list ive done (or trying

MySQL issue
I am taking sentences through a form on page. Then checking some condition and trying to insert them

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

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