Jump to content

Recommended Posts

Hello all,

I am creating a timesheet application that will display a date such as Jan 1st 2007 to Jan 15th 2007.  How do i code this in php to automatically to display each two week period (from saturday to saturday) based on what day it is?  Such as today is the 31st so if the end of the pay period was on Friday Feb 2nd, the page would display Jan 19th to Feb 2nd.

Thank you!

 

 

Link to comment
https://forums.phpfreaks.com/topic/36597-creating-a-bi-weekly-calendar/
Share on other sites

the way i did this was using an unixtimstamp and then adding to it...

 

$today = time();

// 1209600 = # of seconds in a two week period

$twoweeks_date = $today + 1209600;

 

this will give you the date range you need, there are other ways to do this.... and it all depends on how you want to display your calendar, but at least this way you have your start & ending points

 

btw, you will see posts that this method doesn't totally account for daylight savings, blah blah blah... which is true. however most of the time this will be sufficient.

Hey thanks that looks pretty good, but perhaps is there a way to do it in non unix timestamp or is there an easy way to convert it to english time?  This is how i am displaying the calendar

picture4ga7.png

I will probably put above the calendar "Week Jan 1st- Jan 15th"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.