Assemble date/time from month informed by user

Asked

Viewed 280 times

3

I have the month entered by the user. ex:

$mes = 11;

Now I want to pick up this month and return the current (day/year/hour) + the month reported:

2015-11-08 14:44:00
  • And where do the day and time information come from? whatever or whether it comes from the user? in what format?

  • I want to get the current server date/time same.

  • And what output format do you want? Unix timestamp or formatted?

  • @Sergio Unix timestamp

  • @Earendul the day/year/hour is the current month. Only the month is informed by the user.

  • I got it, I thought you wanted the current weather. So it wouldn’t be current if the user informed a month that has passed or is to come..

Show 1 more comment

2 answers

6


It can be done like this.

$data = date("Y-".$mes_informado."-d H:i:s")

0

Try:

<?php

$mes = 11;
$data = substr_replace( date( 'Y--d H:i:s' ), $mes, 5, 0 );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.