Page 1 of 1
i want to diaplay which week this is from a selected date
Posted: Thu Aug 10, 2006 7:14 am
by phpchild
hi,
now i am stuggling with date format problem. i want to display a week from the selected date from the database.
for example
if i retrive the date like 6-7-2006 from the database, it should be show like 01-07-2006 to 07-07-2006 from database
thank U
Posted: Thu Aug 10, 2006 7:18 am
by volka
Is it just any database or a specific one, meaning: can you use "special" functions of your database or should it be generic/php code?
Posted: Thu Aug 10, 2006 7:43 am
by phpchild
hi
thanks for ur reply.
i don't know any special functions if u know please tell me
Posted: Thu Aug 10, 2006 7:59 am
by volka
e.g. there is WEEK(date[,mode]) and WEEKDAY(date) for mysql,
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
and strtotime for php,
http://de2.php.net/strtotime
and date,
http://de2.php.net/date
really depends on what you have and what you want to use.
Posted: Thu Aug 10, 2006 8:08 am
by phpchild
hi
but i want to display starting date and ending date from the week
like
if i choose 6-07-2006
it should show
starting date 01-07-06
ending date 07-07-06
Posted: Thu Aug 10, 2006 8:35 am
by volka
From saturday to friday? That's a strange week. Anyway...
It's an easy task with strtotime in php.
Code: Select all
<?php
$tsEnd = strtotime('2006-07-06 friday');
$tsStart = strtotime('last saturday', $tsEnd);
echo date('d.m.Y', $tsEnd), " \n", date('d.m.Y', $tsStart);
?>