|
|
|
/******************************************************************************
formating MySQL Timestamp to get a propper Output
Author : Andreas Kempf
Date : 1998-04-08
$svDate : The timestamp from MySQL
$svDateOutput : YYYY-MM-DD hh:mm:ss
DD.MM.YYYY or whatsoever
year = YYYY
month = MM
day = DD
hour = hh
minute= mm
second= ss
******************************************************************************/
<?
function FncChangeTimestamp ($svDate, $svDateOutput)
{
$year = substr($svDate,0,4);
$month = substr($svDate,4,2);
$day = substr($svDate,6,2);
$hour = substr($svDate,8,2);
$minute= substr($svDate,10,2);
$sec = substr($svDate,12,2);
$svDateOutput = ereg_replace ("YYYY", $year, $svDateOutput);
$svDateOutput = ereg_replace ("MM", $month, $svDateOutput);
$svDateOutput = ereg_replace ("DD", $day, $svDateOutput);
$svDateOutput = ereg_replace ("hh", $hour, $svDateOutput);
$svDateOutput = ereg_replace ("mm", $minute, $svDateOutput);
$svDateOutput = ereg_replace ("ss", $sec, $svDateOutput);
return $svDateOutput;
};
?> |
|
| List people whose birthdays fall on the current Day and Month
Categories : Databases, Date Time, MySQL, PHP | | | In Mysql, the 'datetime' data type is used to store date that looks like '2007-10-16 16:26:30'. we are going to design a function called mysqldate() that takes a mysql date and output format as input and outputs a well formated date. Categories : PHP, Date Time, Databases, MySQL | | | Data Retrieve from Mysql using AJAX with PHP Categories : PHP, AJAX, Date Time, Databases, MySQL | | | Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays. Categories : Calendar, Date Time, PHP, Databases, MySQL | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | How to Insert a Date Format Into MySQL from PHP Categories : PHP, Databases, MySQL, Date Time, Beginner Guides | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time | | | Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields Categories : MySQL, Date Time, PHP, Databases | | | Simple function to return the number of days in a time span between 2 given dates. Categories : PHP, Date Time, MySQL, Databases | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | | | Phorum, MySQL, Language, UK date format, MySQL UK Date format Categories : PHP, Date Time, Strings, MySQL, Databases | | | PHP Calendar Web App Categories : PHP, Databases, MySQL, Date Time, Calendar | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | |
| | | | Camden wrote : 265
It`s so much easier just to use one of PHP`s built in date
formatting functions.
For example:
echo strftime ("%b %d %Y %H:%M:%
S",$TimeStamp])."\n";
| | | | Camden wrote : 266
Good job on the code kempf - just noticed the MySQL
timestamps don`t convert with the built in functions.
| | | | Jamez Picard wrote : 1052
You just have do your MySQL query right and you can use the date() function.
// SELECT UNIX_TIMESTAMP(your_mysql_timestamp_column_here) as yourdate from yourtable
echo date("l, F jS, Y at g:i", $yourdate);
| | | | Sander van der Linden wrote : 1230
that might be so, but i have tables with lots of fields
and it gets on your nerves if you HAVE to specify for
each field to query what its name is and how to read it
when you need all the fields anyway
| | | | Sander van der Linden wrote : 1231
this is the same function modified for DATETIME:
thanks for it btw, very handy
<?
function func_change_datetime($svDate, $svDateOutput)
{
$year = substr($svDate,0,4);
$month = substr($svDate,5,2);
$day = substr($svDate,8,2);
$hour = substr($svDate,11,2);
$minute= substr($svDate,14,2);
$sec = substr($svDate,17,2);
$svDateOutput = ereg_replace ("YYYY", $year, $svDateOutput);
$svDateOutput = ereg_replace ("MM", $month, $svDateOutput);
$svDateOutput = ereg_replace ("DD", $day, $svDateOutput);
$svDateOutput = ereg_replace ("hh", $hour, $svDateOutput);
$svDateOutput = ereg_replace ("mm", $minute, $svDateOutput);
$svDateOutput = ereg_replace ("ss", $sec, $svDateOutput);
echo $svDateOutput;
};
?>
| | | | taoufik bouaraar wrote :1251
i can`t get this code working
what should i define as var`s ... and what should i do to output the result "i`m a beginner"
Kind Regards
| |
|
|