user2709207
user2709207

Reputation: 27

get only the M month from a date in php

i have this french date format :

(Samedi, Aout 31, 2013)

and i want to get only the (M) of the date, for example for August i only want the (Aug)

PS : August in english = Aout in french

Upvotes: 0

Views: 327

Answers (3)

user1781498
user1781498

Reputation:

try: explode(" ","Samedi, Aout 31, 2013")[1]

Upvotes: 0

jterry
jterry

Reputation: 6269

$stamp = strtotime("Samedi, Aout 31, 2013");
$month = strftime("%b", $stamp);

...or more concisely:

echo strftime("%b", strtotime("Samedi, Aout 31, 2013"));

Upvotes: 0

jerdiggity
jerdiggity

Reputation: 3665

<?php
  $date = 'Samedi, Aout 31, 2013';
  $time = strtotime($date);
  $month_only = date('M', $time);
  echo $month_only;

Upvotes: 1

Related Questions