GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Question (https://gfy.com/showthread.php?t=53128)

ServerGenius 03-09-2002 05:44 AM

PHP Question
 
Hi,

How can I convert a mysql timestamp into a date:

for example: I have 20020308205258 in my date field
and want to convert that to 08-09-2002 ?

Thanks in advance!

DynaMite

Robert 03-09-2002 06:12 AM

$date="20020308205258";
$date=ERegI_Replace("(^[0-9]{4})([0-9]{2})([0-9]{2})","\\3-\\2-\\1",$date);

would do the job, I didnt test it . It was just born in my drunk mind :stoned

ServerGenius 03-09-2002 06:18 AM

Thank you very much....!!!!


DynaMite

Robert 03-09-2002 06:37 AM

you're welcome :)

a little modification:

$date="20020308205258";
$date=ERegI_Replace("(^[0-9]{4})([0-9]{2})([0-9]{2}).*$","\\3-\\2-\\1",$date);

ServerGenius 03-09-2002 06:59 AM

I noticed that....had already been fixed :D

Thanks again very much appreciated!

DynaMite


All times are GMT -7. The time now is 12:43 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123