获取整个星期日期从星期日到星期六从给定日期开始

时间:2018-01-03 08:55:39

标签: php

大家好,我在php工作,我的要求是从给定日期获得完整的工作日期,因为我需要计算每周工作时间。周必须从星期日到星期六开始,而不是星期一到星期日。除了周日之外,我的代码适用于其他几天。这意味着如果从星期一到星期六提供任何日期,它可以正常工作,但如果我给出了星期日的日期,它会给出上周的日期。请检查我的代码,并告诉我更好的解决方案。

WARN:   WELD-000718: No EEModuleDescriptor defined for bean archive with ID: project1-web-1.0-SNAPSHOT_war.war. @Initialized and @Destroyed events for ApplicationScoped may be fired twice.
INFORMATION:   file:/home/richter/project1-aggregator/project1/project1-ear/target/gfdeploy/project1-ear/lib/project1-jar-1.0-SNAPSHOT.jar_richtercloud_project1-ifaces_jar_1.0-SNAPSHOTPU logout successful
WARNUNG:   Input stream has been finalized or forced closed without being explicitly closed; stream instantiation reported in following stack trace
java.lang.Throwable
    at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.<init>(ASURLClassLoader.java:1284)
    at com.sun.enterprise.loader.ASURLClassLoader$InternalJarURLConnection.getInputStream(ASURLClassLoader.java:1392)
    at java.net.URL.openStream(URL.java:1045)
    at org.javamoney.moneta.spi.MonetaryConfig.<init>(MonetaryConfig.java:52)
    at org.javamoney.moneta.spi.MonetaryConfig.<clinit>(MonetaryConfig.java:39)
    at org.javamoney.moneta.internal.DefaultMonetaryCurrenciesSingletonSpi.getDefaultProviderChain(DefaultMonetaryCurrenciesSingletonSpi.java:99)
    at org.javamoney.moneta.internal.DefaultMonetaryCurrenciesSingletonSpi.collectProviders(DefaultMonetaryCurrenciesSingletonSpi.java:69)
    at org.javamoney.moneta.internal.DefaultMonetaryCurrenciesSingletonSpi.getCurrencies(DefaultMonetaryCurrenciesSingletonSpi.java:42)
    at javax.money.spi.MonetaryCurrenciesSingletonSpi.getCurrency(MonetaryCurrenciesSingletonSpi.java:72)
    at javax.money.Monetary.getCurrency(Monetary.java:422)
    at richtercloud.project1.jar.entities.offer.AbstractOffer.<init>(AbstractOffer.java:205)
    at richtercloud.project1.jar.entities.offer.OfferEdit.<init>(OfferEdit.java:77)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.eclipse.persistence.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:3982)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:649)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:632)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:568)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:799)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:743)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:358)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:207)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:114)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:225)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:525)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:240)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:170)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:926)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:435)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:220)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:508)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:544)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:540)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:570)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:562)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:561)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1469)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1851)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1727)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:483)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
    at java.lang.Thread.run(Thread.java:748)

INFORMATION:   EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
INFORMATION:   file:/home/richter/project1-aggregator/project1/project1-ear/target/gfdeploy/project1-ear/lib/project1-jar-1.0-SNAPSHOT.jar_richtercloud_project1-ifaces_jar_1.0-SNAPSHOTPU login successful
INFORMATION:   Portable JNDI names for EJB DefaultAppDataService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultAppDataService!richtercloud.project1.jar.controller.AppDataService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultAppDataService]
INFORMATION:   [FileBackingStore::initialize] Successfully Created and initialized store. Working dir: /home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultReviewService-99309011086253301; Configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultReviewService-99309011086253301-BackingStore', shortUniqueName='99309011086253301', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultReviewService-99309011086253301', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@7e1b1d92}}
INFORMATION:   StatefulContainerbuilder instantiated store: org.glassfish.ha.store.adapter.file.FileBackingStore@5d2b6144, with ha-enabled [false], and backing store configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultReviewService-99309011086253301-BackingStore', shortUniqueName='99309011086253301', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultReviewService-99309011086253301', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@7e1b1d92}}
INFORMATION:   Portable JNDI names for EJB DefaultReviewService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultReviewService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultReviewService!richtercloud.project1.jar.controller.ReviewService]
INFORMATION:   [FileBackingStore::initialize] Successfully Created and initialized store. Working dir: /home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultOfferService-99309011086226578; Configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultOfferService-99309011086226578-BackingStore', shortUniqueName='99309011086226578', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultOfferService-99309011086226578', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@657d1a8b}}
INFORMATION:   StatefulContainerbuilder instantiated store: org.glassfish.ha.store.adapter.file.FileBackingStore@6a9b2d3b, with ha-enabled [false], and backing store configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultOfferService-99309011086226578-BackingStore', shortUniqueName='99309011086226578', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultOfferService-99309011086226578', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@657d1a8b}}
INFORMATION:   Portable JNDI names for EJB DefaultOfferService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultOfferService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultOfferService!richtercloud.project1.jar.controller.OfferService]
INFORMATION:   Portable JNDI names for EJB DefaultInitService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultInitService!richtercloud.project1.jar.controller.InitService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultInitService]
INFORMATION:   Portable JNDI names for EJB DatabaseUserService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DatabaseUserService!richtercloud.project1.jar.controller.UserService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DatabaseUserService!richtercloud.project1.ejb.DatabaseUserService]
INFORMATION:   Portable JNDI names for EJB Offer: [java:global/project1-ear/project1-web-1.0-SNAPSHOT/Offer!richtercloud.project1.web.rest.Offer, java:global/project1-ear/project1-web-1.0-SNAPSHOT/Offer]
INFORMATION:   Portable JNDI names for EJB User: [java:global/project1-ear/project1-web-1.0-SNAPSHOT/User!richtercloud.project1.web.rest.User, java:global/project1-ear/project1-web-1.0-SNAPSHOT/User]
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
WARNUNG:   The following warnings have been detected: WARNING: Parameter interceptedBean of type javax.enterprise.inject.spi.Bean<?> from private javax.enterprise.inject.spi.Bean<?> org.glassfish.soteria.cdi.RememberMeInterceptor.interceptedBean is not resolvable to a concrete type.

WARNUNG:   The following warnings have been detected: WARNING: Parameter interceptedBean of type javax.enterprise.inject.spi.Bean<?> from private javax.enterprise.inject.spi.Bean<?> org.glassfish.soteria.cdi.LoginToContinueInterceptor.interceptedBean is not resolvable to a concrete type.

INFORMATION:   Registering WebSocket filter for url pattern /*
INFORMATION:   Using OmniFaces version 2.6.7
INFORMATION:   Initializing Soteria 1.0 for context '/project1-web'
INFORMATION:   Mojarra 2.2.14 (-SNAPSHOT 20170628-1326 unable to get svn info) für Kontext '/project1-web' wird initialisiert.
INFORMATION:   Running on PrimeFaces 6.1
WARN:   WELD-000718: No EEModuleDescriptor defined for bean archive with ID: project1-web-1.0-SNAPSHOT_war.war. @Initialized and @Destroyed events for ApplicationScoped may be fired twice.
INFORMATION:   Loading application [project1-ear#project1-web-1.0-SNAPSHOT.war] at [/project1-web]
INFORMATION:   project1-ear was successfully deployed in 18.172 milliseconds.

4 个答案:

答案 0 :(得分:1)

来自source

以下是您要查找的代码段,

// set current date
$date = '01/03/2018';
// parse about any English textual datetime description into a Unix timestamp 
$ts = strtotime($date);
// calculate the number of days since Monday
$dow = date('w', $ts);
$offset = $dow - 1;
if ($offset < 0) {
    $offset = 6;
}
// calculate timestamp for the Monday
$ts = $ts - $offset*86400;
// loop from Monday till Sunday 
for ($i = 0; $i < 7; $i++, $ts += 86400){
    print date("m/d/Y l", $ts) . "\n";
}

以下是demo

如果您需要正常的标准格式代码,

这是你的代码段,

// set current date
$date = '2018-01-03';
// parse about any English textual datetime description into a Unix timestamp
$ts = strtotime($date);
// calculate the number of days since Monday
$dow    = date('w', $ts);
$offset = $dow - 1;
if ($offset < 0) {
    $offset = 6;
}
// calculate timestamp for the Monday
$ts = $ts - $offset * 86400;
// loop from Monday till Sunday
for ($i = 0; $i < 7; $i++, $ts += 86400) {
    print date("Y-m-d l", $ts) . "\n";
}

以下是demo

修改

根据您的要求,现在周将从周日开始到周六

<?php
// set current date
$date = '2018-01-03';
// parse about any English textual datetime description into a Unix timestamp
$ts = strtotime($date);
// calculate the number of days since Sunday
$dow    = date('w', $ts);
$offset = $dow;
if ($offset < 0) {
    $offset = 6;
}
// calculate timestamp for the Sunday
$ts = $ts - $offset * 86400;
// loop from Sunday till Saturday
for ($i = 0; $i < 7; $i++, $ts += 86400) {
    print date("Y-m-d l", $ts) . "\n";
}

答案 1 :(得分:1)

使用DateTimeDateIntervalDatePeriod类,您可以这样做

function getperiod( $start ){
    return new DatePeriod(
        new DateTime( $start ),
        new DateInterval('P1D'),
        new DateTime( date( DATE_COOKIE, strtotime( $start . '+ 7days' ) ) )
    );
}

$start='2018-01-07';

$period=getperiod( $start );
foreach( $period as $date ){
    echo $date->format('l -> Y-m-d') . '<br />';
}

返回

Sunday -> 2018-01-07
Monday -> 2018-01-08
Tuesday -> 2018-01-09
Wednesday -> 2018-01-10
Thursday -> 2018-01-11
Friday -> 2018-01-12
Saturday -> 2018-01-13

或者,通过修改getperiod函数的参数,您可以使该功能更加灵活。

function getperiod( $start, $interval='P1D', $days=7 ){
    return new DatePeriod(
        new DateTime( $start ),
        new DateInterval( $interval ),
        new DateTime( date( DATE_COOKIE, strtotime( $start . '+ '.$days.' days' ) ) )
    );
}

$start='2018-01-07';
$days=array();

$period=getperiod( $start );
foreach( $period as $date ){
    $days[]=$date->format('Y-m-d');
}
echo '<pre>',print_r($days,true),'</pre>';

例如:找到明年的每个星期天

$period=getperiod( $start,'P7D', 365 );
foreach( $period as $date ){
    $days[]=$date->format('Y-m-d');
}
echo '<pre>',print_r($days,true),'</pre>';

确保计算开始于Sunday,其数值为7

function getperiod( $start, $interval='P1D', $days=7 ){
    return new DatePeriod(
        new DateTime( $start ),
        new DateInterval( $interval ),
        new DateTime( date( DATE_COOKIE, strtotime( $start . '+ '.$days.' days' ) ) )
    );
}

/* A date from which to begin calculations */
$start='2018-01-01';

/* Array to store output */
$days=array();

/* integer to represent which day of the week to operate upon */
$startday = 7;

/* Output format for resultant dates */
$output='Y-m-d';

/* Calculate initial startdate given above variables */
$start=date( DATE_COOKIE, strtotime( $start . ' + ' . ( $startday - date( 'N', strtotime( $start ) ) ) . ' days' ) );

/* Get the period range */
$period=getperiod( $start );
foreach( $period as $date ){
    /* store output in desired format */
    $days[]=$date->format( $output );
}

/* do something with data */
echo '<pre>',print_r($days,true),'</pre>';

答案 2 :(得分:0)

试试这个:

$days = array();                
$ddate = "2018-01-07";
$date = new DateTime($ddate);
$week = $date->format("N")==7?$date->modify("+1 week")->format("W"):$date->format("W");
$y =    date("Y", strtotime($ddate));
echo "Weeknummer: $week"."<br>";
echo "Year: $y"."<br>";             
for($day=0; $day<=6; $day++)
{
    $days[$day] = date('Y-m-d', strtotime($y."W".$week.$day))."<br>";
}               
print_r($days);

答案 3 :(得分:0)

<?php
$days = array();                
$ddate = "2018-01-07";
$y =    date("Y", strtotime($ddate));
if(date("l", strtotime($ddate))=='Sunday'){
    $ddate = date("Y-m-d ", strtotime($ddate. "+1 day"));
}
$date = new DateTime($ddate);
$week = $date->format("W");
echo "<br/>";
echo "Weeknummer: $week"."<br>";
echo "Year: $y"."<br>";             
for($day=0; $day<=6; $day++)
{
    $days[$day] = date('Y-m-d', strtotime($y."W".$week.$day))."<br>";

}               
print_r($days);





?>